httk.serve.optimade.api¶
Public helpers for creating and running generic OPTIMADE applications.
Functions¶
|
Create an ASGI application serving an OPTIMADE API for a backend or store. |
|
Create an ASGI application for an OPTIMADE index meta-database. |
|
Serve an OPTIMADE API for a backend or entry store with a development server. |
Module Contents¶
- httk.serve.optimade.api.create_asgi_app(adapter, config=None, *, baseurl=None, debug=False, report_level='warning', report_context_levels=None)[source]¶
Create an ASGI application serving an OPTIMADE API for a backend or store.
An absent
baseurlmakes the application derive a mount-aware URL from the request. An explicit value is authoritative.- Parameters:
adapter (httk.serve.optimade.model.results.OptimadeAdapter | httk.store.EntryStore) – Backend providing the served schema/query callback, or an entry store whose configured OPTIMADE families are discovered lazily.
config (httk.serve.optimade.model.config.OptimadeConfig | None) – Optional service configuration.
baseurl (str | None) – Public API base URL, or
Nonefor request-based derivation.debug (bool) – Enable application and backend diagnostics.
report_level (str | int) – Minimum report level collected per request.
report_context_levels (collections.abc.Mapping[str, str | int] | None) – Context-specific report levels.
- Returns:
Configured serving application.
- Return type:
- httk.serve.optimade.api.create_index_asgi_app(config, *, baseurl=None, debug=False, report_level='warning', report_context_levels=None)[source]¶
Create an ASGI application for an OPTIMADE index meta-database.
The index serves only discovery, links, and unversioned version negotiation. It has no backend adapter and performs no query calls. The supplied configuration is retained as the response metadata source; the composed application’s caller owns its lifetime and configuration.
- Parameters:
config (httk.serve.optimade.model.config.OptimadeIndexConfig) – Validated index metadata and configured database links.
baseurl (str | None) – Authoritative public index URL, or
Nonefor mount-aware derivation from each request.debug (bool) – Enable Starlette diagnostics.
report_level (str | int) – Minimum report level collected per request.
report_context_levels (collections.abc.Mapping[str, str | int] | None) – Context-specific report levels.
- Returns:
Configured serving application.
- Raises:
TypeError – If
configis not anOptimadeIndexConfig.- Return type:
- httk.serve.optimade.api.serve(adapter, config=None, *, host='127.0.0.1', port=8080, baseurl=None, debug=False, report_level='warning', report_context_levels=None)[source]¶
Serve an OPTIMADE API for a backend or entry store with a development server.
- Parameters:
adapter (httk.serve.optimade.model.results.OptimadeAdapter | httk.store.EntryStore) – Backend providing the served schema/query callback, or an entry store whose configured OPTIMADE families are discovered lazily.
config (httk.serve.optimade.model.config.OptimadeConfig | None) – Optional service configuration.
host (str) – Interface or hostname to bind.
port (int) – TCP port to bind.
baseurl (str | None) – Public API base URL, or
Noneto derive the local URL.debug (bool) – Enable application and backend diagnostics.
report_level (str | int) – Minimum report level collected per request.
report_context_levels (collections.abc.Mapping[str, str | int] | None) – Context-specific report levels.