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 Response(IResponse): (source)
Known subclasses: orionis.http.HTMLResponse, orionis.http.JSONResponse, orionis.http.PlainTextResponse, orionis.http.RedirectResponse, orionis.http.StreamingResponse
Constructor: Response(content, status_code, headers, media_type, ...)
Undocumented
| Method | __init__ |
Initialize the BaseResponse object. |
| Method | add |
Add a header to the response. |
| Method | delete |
Delete a cookie by setting its expiration to the past. |
| Method | get |
Return the response body as bytes. |
| Method | get |
Return the data queued by withFlash() for the session flash bag. |
| Method | get |
Get the values for a header. |
| Method | get |
Return the media type of the response. |
| Method | get |
Return the headers as a list of (key, value) byte tuples. |
| Method | get |
Return the HTTP status code of the response. |
| Method | get |
Return the response stream if present. |
| Method | get |
Return the headers as a list of (key, value) string tuples. |
| Method | has |
Check if a header is present. |
| Method | has |
Check if the response has a stream. |
| Method | remove |
Remove a header from the response. |
| Method | render |
Render the content to bytes. |
| Async Method | run |
Run the background task if it exists. |
| Method | set |
Set a cookie header in the response. |
| Method | set |
Set a header, replacing any existing values. |
| Method | with |
Attach a cookie and return the response for chaining. |
| Method | with |
Attach several cookies at once and return the response. |
| Method | with |
Flash validation errors for the next request. |
| Method | with |
Flash a status message into the session and return the response. |
| Method | with |
Flash the submitted payload so the next request can repopulate it. |
| Method | without |
Expire a cookie and return the response for chaining. |
| Class Variable | __slots__ |
Undocumented |
| Class Variable | charset |
Undocumented |
| Instance Variable | _body |
Undocumented |
| Instance Variable | _flash |
Undocumented |
| Instance Variable | _headers |
Undocumented |
| Instance Variable | _raw |
Undocumented |
| Instance Variable | _stream |
Undocumented |
| Instance Variable | background |
Undocumented |
| Instance Variable | media |
Undocumented |
| Instance Variable | status |
Undocumented |
Any = None, status_code: HTTPStatus | int = 200, headers: Mapping[ str, str] | None = None, media_type: str | None = None, background: BackgroundTask | None = None):
(source)
¶
orionis.http.HTMLResponse, orionis.http.JSONResponse, orionis.http.PlainTextResponse, orionis.http.RedirectResponse, orionis.http.StreamingResponseInitialize the BaseResponse object.
| 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 | The headers to include in the response. |
mediastr | None, optional | The media type of the response. |
background:BackgroundTask | None, optional | The background task to run after response. |
| Returns | |
None | This method does not return a value. |
Return the response body as bytes.
| Returns | |
bytes | None | The response body as bytes, or None if not set. |
orionis.http.EventStreamResponseReturn the response stream if present.
| Returns | |
AsyncIterable[bytes] | None | The response stream, or None if not set. |
orionis.http.JSONResponseRender the content to bytes.
| Parameters | |
content:Any | The content to render. |
| Returns | |
bytes | The rendered content as bytes. |
str, value: str = '', *, max_age: int | None = None, expires: datetime | str | int | None = None, path: str | None = '/', domain: str | None = None, secure: bool = False, http_only: bool = False, same_site: Literal[ 'lax', 'strict', 'none'] | None = 'lax', partitioned: bool = False):
(source)
¶
Set a cookie header in the response.
| Parameters | |
key:str | The cookie name. |
value:str, optional | The cookie value. Defaults to an empty string. |
maxint | None, optional | The maximum age of the cookie in seconds. |
expires:datetime | str | int | None, optional | The expiration date of the cookie. |
path:str | None, optional | The path for which the cookie is valid. |
domain:str | None, optional | The domain for which the cookie is valid. |
secure:bool, optional | Whether the cookie is secure. |
httpbool, optional | Whether the cookie is HTTP only. |
samestr | None, optional | The SameSite policy for the cookie. |
partitioned:bool, optional | Whether the cookie is partitioned. |
| Returns | |
None | This method does not return a value. |
str, value: str = '', *, max_age: int | None = None, expires: datetime | str | int | None = None, path: str | None = '/', domain: str | None = None, secure: bool = False, http_only: bool = False, same_site: Literal[ 'lax', 'strict', 'none'] | None = 'lax', partitioned: bool = False) -> Self:
(source)
¶
Attach a cookie and return the response for chaining.
| Parameters | |
key:str | The cookie name. |
value:str, optional | The cookie value. Defaults to an empty string. |
maxint | None, optional | The maximum age of the cookie in seconds. |
expires:datetime | str | int | None, optional | The expiration date of the cookie. |
path:str | None, optional | The path for which the cookie is valid. |
domain:str | None, optional | The domain for which the cookie is valid. |
secure:bool, optional | Whether the cookie is secure. |
httpbool, optional | Whether the cookie is HTTP only. |
samestr | None, optional | The SameSite policy for the cookie. |
partitioned:bool, optional | Whether the cookie is partitioned. |
| Returns | |
Self | The same response instance, allowing fluent chaining. |
Flash validation errors for the next request.
Errors are read back in templates through the errors global.
| Parameters | |
errors:Mapping[str, Any] | Exception | Mapping of field to message(s), or a validation exception. |
| Returns | |
Self | The same response instance, allowing fluent chaining. |
Flash a status message into the session and return the response.
The value survives for exactly one subsequent request and is read back in templates through the flash() global.
| Parameters | |
key:str | Flash data key. |
value:Any, optional | Value to flash. |
| Returns | |
Self | The same response instance, allowing fluent chaining. |
Flash the submitted payload so the next request can repopulate it.
Values are read back in templates through the old() global. Credential-like fields such as password are stripped.
| Parameters | |
values:Mapping[str, Any] | Submitted form payload to remember. |
| Returns | |
Self | The same response instance, allowing fluent chaining. |
str, *, path: str = '/', domain: str | None = None) -> Self:
(source)
¶