httk.serve.optimade.runtime¶
Public ASGI application and development-server helpers.
Submodules¶
Functions¶
|
Create a mount-aware ASGI application for an explicit schema and query callback. |
|
Run an ASGI application with Uvicorn. |
Package Contents¶
- httk.serve.optimade.runtime.create_app(*, query_function, config, schema, baseurl=None, debug=False, report_level='warning', report_context_levels=None, snapshot_cutoff_ns=None)[source]¶
Create a mount-aware ASGI application for an explicit schema and query callback.
An explicit
baseurlis authoritative. Without one, the application derives links from the request origin and ASGIroot_path, preserving the mount path and exactly one version segment. CORS remains disabled unlessconfig.cors_originscontains a bounded exact allow-list; request report collections are merged into response warnings, including error responses.- Parameters:
query_function (httk.serve.optimade.model.results.QueryFunction) – Callback that executes entry queries.
config (httk.serve.optimade.model.config.OptimadeConfig) – Service and runtime configuration.
schema (httk.serve.optimade.schema.served.ServedSchema) – Required schema describing served entries and properties.
baseurl (str | None) – Authoritative public API base URL, or
Nonefor derivation.debug (bool) – Enable Starlette 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.
snapshot_cutoff_ns (httk.serve.optimade.engine.processing.SnapshotCutoff | None) – Optional stored-backend snapshot capability.
- Returns:
Configured Starlette ASGI application.
- Raises:
ValueError – If configured CORS origins are invalid or excessive.
- Return type:
- httk.serve.optimade.runtime.run_dev_server(*, app, host, port)[source]¶
Run an ASGI application with Uvicorn.
- Parameters:
app (httk.serve.http.ServeApp) – ASGI application to serve.
host (str) – Interface or hostname to bind.
port (int) – TCP port to bind.