THE ORIONIS API
Build with clarity.
Explore the building blocks of an async-first Python framework. Every module, class, and method — connected, searchable, and ready to build with.
class ResponseFactory: (source)
Build every kind of HTTP response from a single entry-point.
Controllers use the module-level response instance so they do
not need to import a different class for each response type:
return response.view("users.index", users=users)
return response.json({"ok": True})
return response.redirect("/login")
| Method | download |
Build a file response forced to be downloaded as an attachment. |
| Method | event |
Build a streaming response carrying UTF-8 server-sent events. |
| Method | file |
Build a response streaming a file from disk. |
| Method | html |
Build a response carrying raw HTML content. |
| Method | json |
Build a response serialising the content as JSON. |
| Method | make |
Build a bare response with full control over its content. |
| Method | no |
Build an empty response, typically for 204 No Content. |
| Method | redirect |
Build a response redirecting the client to another URL. |
| Method | stream |
Build a response streaming byte chunks to the client. |
| Method | text |
Build a response carrying plain text content. |
| Method | view |
Render a template as an awaitable, chainable HTML response. |
| Class Variable | __slots__ |
Undocumented |
str | Path, filename: str | None = None, headers: Mapping[ str, str] | None = None, media_type: str | None = None, background: BackgroundTask | None = None) -> FileResponse:
(source)
¶
Build a file response forced to be downloaded as an attachment.
| Parameters | |
path:str | Path | Path to the file to serve. |
filename:str | None, optional | Name advertised to the client; defaults to the file name. |
headers:Mapping[str, str] | None, optional | Extra headers to include. |
mediastr | None, optional | Media type of the file; guessed from the path when omitted. |
background:BackgroundTask | None, optional | Task to run after the response is sent. |
| Returns | |
FileResponse | The configured attachment response. |
AsyncIterable[ ServerSentEvent | str] | Iterable[ ServerSentEvent | str], status_code: HTTPStatus | int = 200, headers: Mapping[ str, str] | None = None, background: BackgroundTask | None = None) -> EventStreamResponse:
(source)
¶
Build a streaming response carrying UTF-8 server-sent events.
| Parameters | |
content:AsyncIterable[ServerSentEvent | str] | Iterable[ServerSentEvent | str] | Typed events or text payloads, consumed lazily during delivery. |
statusHTTPStatus | int, optional | HTTP status code for the response. |
headers:Mapping[str, str] | None, optional | Extra headers; Content-Length is discarded. |
background:BackgroundTask | None, optional | Task to run after successful delivery and stream cleanup. |
| Returns | |
EventStreamResponse | The configured server-sent event response. |
str | Path, status_code: HTTPStatus | int = 200, headers: Mapping[ str, str] | None = None, media_type: str | None = None, filename: str | None = None, chunk_size: int = 64 * 1024, background: BackgroundTask | None = None) -> FileResponse:
(source)
¶
Build a response streaming a file from disk.
| Parameters | |
path:str | Path | Path to the file to serve. |
statusHTTPStatus | int, optional | The HTTP status code for the response. |
headers:Mapping[str, str] | None, optional | Extra headers to include. |
mediastr | None, optional | Media type of the file; guessed from the path when omitted. |
filename:str | None, optional | Name advertised in the Content-Disposition header. |
chunkint, optional | Size of the chunks read from disk. |
background:BackgroundTask | None, optional | Task to run after the response is sent. |
| Returns | |
FileResponse | The configured file response. |
str | bytes = '', status_code: HTTPStatus | int = 200, headers: Mapping[ str, str] | None = None, background: BackgroundTask | None = None) -> HTMLResponse:
(source)
¶
Build a response carrying raw HTML content.
| Parameters | |
content:str | bytes, optional | HTML content to send. |
statusHTTPStatus | int, optional | The HTTP status code for the response. |
headers:Mapping[str, str] | None, optional | Extra headers to include. |
background:BackgroundTask | None, optional | Task to run after the response is sent. |
| Returns | |
HTMLResponse | The configured HTML response. |
Any, status_code: HTTPStatus | int = 200, headers: Mapping[ str, str] | None = None, background: BackgroundTask | None = None, *, indent: int | None = None, ensure_ascii: bool = False, separators: tuple[ str, str] | None = None, default: Any | None = None) -> JSONResponse:
(source)
¶
Build a response serialising the content as JSON.
| Parameters | |
content:Any | Content to serialise as JSON. |
statusHTTPStatus | int, optional | The HTTP status code for the response. |
headers:Mapping[str, str] | None, optional | Extra headers to include. |
background:BackgroundTask | None, optional | Task to run after the response is sent. |
indent:int | None, optional | Indentation level for pretty-printing JSON. |
ensurebool, optional | Whether to escape non-ASCII characters. |
separators:tuple[str, str] | None, optional | Item and key separators for JSON output. |
default:Any | None, optional | Custom encoder for unsupported types. |
| Returns | |
JSONResponse | The configured JSON response. |
Any = None, status_code: HTTPStatus | int = 200, headers: Mapping[ str, str] | None = None, media_type: str | None = None, background: BackgroundTask | None = None) -> Response:
(source)
¶
Build a bare response with full control over its content.
| Parameters | |
content:Any, optional | The response content or stream. |
statusHTTPStatus | int, optional | The HTTP status code for the response. |
headers:Mapping[str, str] | None, optional | Extra headers to include. |
mediastr | None, optional | Media type advertised for the content. |
background:BackgroundTask | None, optional | Task to run after the response is sent. |
| Returns | |
Response | The configured response. |
HTTPStatus | int = 204, headers: Mapping[ str, str] | None = None, background: BackgroundTask | None = None) -> Response:
(source)
¶
Build an empty response, typically for 204 No Content.
| Parameters | |
statusHTTPStatus | int, optional | The HTTP status code for the response. |
headers:Mapping[str, str] | None, optional | Extra headers to include. |
background:BackgroundTask | None, optional | Task to run after the response is sent. |
| Returns | |
Response | The configured empty response. |
str, status_code: HTTPStatus | int = 302, headers: Mapping[ str, str] | None = None, background: BackgroundTask | None = None) -> RedirectResponse:
(source)
¶
Build a response redirecting the client to another URL.
| Parameters | |
url:str | Target URL for the redirection. |
statusHTTPStatus | int, optional | Redirect status code (301, 302, 303, 307, 308). |
headers:Mapping[str, str] | None, optional | Extra headers to include. |
background:BackgroundTask | None, optional | Task to run after the response is sent. |
| Returns | |
RedirectResponse | The configured redirect response. |
AsyncIterable[ bytes] | Iterable[ bytes], status_code: HTTPStatus | int = 200, headers: Mapping[ str, str] | None = None, media_type: str | None = None, background: BackgroundTask | None = None) -> StreamingResponse:
(source)
¶
Build a response streaming byte chunks to the client.
| Parameters | |
content:AsyncIterable[bytes] | Iterable[bytes] | Streaming content source. |
statusHTTPStatus | int, optional | The HTTP status code for the response. |
headers:Mapping[str, str] | None, optional | Extra headers to include. |
mediastr | None, optional | Media type advertised for the stream. |
background:BackgroundTask | None, optional | Task to run after the response is sent. |
| Returns | |
StreamingResponse | The configured streaming response. |
str | bytes = '', status_code: HTTPStatus | int = 200, headers: Mapping[ str, str] | None = None, background: BackgroundTask | None = None) -> PlainTextResponse:
(source)
¶
Build a response carrying plain text content.
| Parameters | |
content:str | bytes, optional | Plain text content to send. |
statusHTTPStatus | int, optional | The HTTP status code for the response. |
headers:Mapping[str, str] | None, optional | Extra headers to include. |
background:BackgroundTask | None, optional | Task to run after the response is sent. |
| Returns | |
PlainTextResponse | The configured plain text response. |
Render a template as an awaitable, chainable HTML response.
| Parameters | |
template:str | Template name using dot notation (e.g. 'users.index') or a relative path (e.g. 'users/index.html'). |
**context:Any | Keyword arguments forwarded as template variables. |
| Returns | |
PendingView | Awaitable proxy that resolves to an HTMLResponse and
accepts chained mutators such as withErrors(). |