httk.serve.http.api

Provide lightweight HTTP applications independent of website sources.

Attributes

Functions

json_get_app(document, *[, path, media_type, profile, ...])

Create a lightweight application serving one live JSON document.

jsonld_get_app(document, *[, path, media_type, ...])

Create a lightweight application serving one live JSON-LD document.

create_file_map_app(files, *[, debug])

Create an application exposing only explicitly mapped files.

Module Contents

type httk.serve.http.api.JsonDocument = Mapping[str, object][source]
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 Link header.

  • cache_control (str | None) – Optional Cache-Control response value.

  • cors_allow_origin (str | None) – Optional Access-Control-Allow-Origin value.

  • debug (bool) – Whether Starlette debug responses are enabled.

Returns:

A mountable application serving the declared JSON resource.

Return type:

httk.serve.http.apptypes.ServeApp

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 Link header.

  • cache_control (str | None) – Optional Cache-Control response value.

  • cors_allow_origin (str | None) – Optional Access-Control-Allow-Origin value.

  • debug (bool) – Whether Starlette debug responses are enabled.

Returns:

A mountable application serving the declared JSON-LD resource.

Return type:

httk.serve.http.apptypes.ServeApp

httk.serve.http.api.create_file_map_app(files, *, debug=False)[source]

Create an application exposing only explicitly mapped files.

Parameters:
Returns:

A mountable application serving the declared files.

Return type:

httk.serve.http.apptypes.ServeApp