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 documentation
class JSONResponse(Response): (source)
Constructor: JSONResponse(content, status_code, headers, background, ...)
Undocumented
| Static Method | _default |
Encode unsupported types for JSON serialization. |
| Method | __init__ |
Initialize a JSONResponse with serialized JSON content. |
| Method | render |
Serialize content to JSON bytes. |
| Constant | _CONTENT |
Undocumented |
| Class Variable | __slots__ |
Undocumented |
| Instance Variable | _json |
Undocumented |
| Instance Variable | _json |
Undocumented |
| Instance Variable | _json |
Undocumented |
| Instance Variable | _json |
Undocumented |
Inherited from Response:
| 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. |
| 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 | 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 |
Encode unsupported types for JSON serialization.
| Parameters | |
obj:Any | The object to encode. |
| Returns | |
Any | The encoded object suitable for JSON serialization. |
| Raises | |
TypeError | If the object cannot be encoded for JSON serialization. |
def __init__(self, content:
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):
(source)
¶
overrides
orionis.http.Response.__init__Initialize a JSONResponse with serialized JSON content.
| Parameters | |
content:Any | Content to serialize as JSON. |
statusHTTPStatus | int, optional | HTTP status code for the response. |
headers:Mapping[str, str] | None, optional | Response headers to include. |
background:BackgroundTask | None, optional | Background task to run after response. |
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 | |
None | This constructor does not return a value. |