httk.serve.http.api¶
Provide lightweight HTTP applications independent of website sources.
Attributes¶
Functions¶
|
Create a lightweight application serving one live JSON document. |
|
Create a lightweight application serving one live JSON-LD document. |
|
Create an application exposing only explicitly mapped files. |
Module Contents¶
- type httk.serve.http.api.JsonDocumentFactory = Callable[[], JsonDocument | Awaitable[JsonDocument]][source]¶
- httk.serve.http.api.json_get_app(document, *, path='/', media_type='application/json', profile=None, cache_control='public, max-age=60', cors_allow_origin='*', debug=False)[source]¶
Create a lightweight application serving one live JSON document.
- Parameters:
document (JsonDocument | JsonDocumentFactory) – JSON mapping or live zero-argument document factory.
path (str) – Canonical root-relative route, normally
/for mounting.media_type (str) – JSON response media type, including optional parameters.
profile (str | None) – Optional profile IRI emitted as an RFC 6906
Linkheader.cache_control (str | None) – Optional
Cache-Controlresponse value.cors_allow_origin (str | None) – Optional
Access-Control-Allow-Originvalue.debug (bool) – Whether Starlette debug responses are enabled.
- Returns:
A mountable application serving the declared JSON resource.
- Return type:
- httk.serve.http.api.jsonld_get_app(document, *, path='/', media_type='application/ld+json', profile=None, cache_control='public, max-age=60', cors_allow_origin='*', debug=False)[source]¶
Create a lightweight application serving one live JSON-LD document.
- Parameters:
document (JsonDocument | JsonDocumentFactory) – JSON-LD mapping or live zero-argument document factory.
path (str) – Canonical root-relative route, normally
/for mounting.media_type (str) – JSON-LD response media type, including optional parameters.
profile (str | None) – Optional profile IRI emitted as an RFC 6906
Linkheader.cache_control (str | None) – Optional
Cache-Controlresponse value.cors_allow_origin (str | None) – Optional
Access-Control-Allow-Originvalue.debug (bool) – Whether Starlette debug responses are enabled.
- Returns:
A mountable application serving the declared JSON-LD resource.
- Return type:
- httk.serve.http.api.create_file_map_app(files, *, debug=False)[source]¶
Create an application exposing only explicitly mapped files.
- Parameters:
files (collections.abc.Mapping[str, str | pathlib.Path]) – Root-relative URL paths mapped to filesystem paths.
debug (bool) – Whether Starlette debug responses are enabled.
- Returns:
A mountable application serving the declared files.
- Return type: