landing¶
OPTIMADE landing page router.
CONFIG: ServerConfig = ServerConfig()
module-attribute
¶
This singleton loads the config from a hierarchy of sources (see
customise_sources
)
and makes it importable in the server code.
ENTRY_COLLECTIONS = {'links': links_coll, 'references': references_coll, 'structures': structures_coll}
module-attribute
¶
__api_version__ = '1.1.0'
module-attribute
¶
router = Router(routes=[Route('/', endpoint=landing)])
module-attribute
¶
get_base_url(parsed_url_request)
¶
Get base URL for current server
Take the base URL from the config file, if it exists, otherwise use the request.
Source code in optimade/server/routers/utils.py
221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 |
|
landing(request)
async
¶
Show a human-readable landing page when the base URL is accessed.
Source code in optimade/server/routers/landing.py
84 85 86 |
|
meta_values(url, data_returned, data_available, more_data_available, schema=None, **kwargs)
¶
Helper to initialize the meta values
Source code in optimade/server/routers/utils.py
50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 |
|
render_landing_page(url)
cached
¶
Render and cache the landing page.
This function uses the template file ./static/landing_page.html
, adapted
from the original Jinja template. Instead of Jinja, some basic string
replacement is used to fill out the fields from the server configuration.
Careful
The removal of Jinja means that the fields are no longer validated as web safe before inclusion in the template.
Source code in optimade/server/routers/landing.py
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 |
|