Flaxon 0.3.0 and Teloce-Py 0.3.0 are available on PyPI. Release instructions are maintained on this site; source links identify the framework snapshot. Check version and upgrade guidance.

Framework source · Markdown

HTTP API


Request

HTTP request object.


Constructor

Request(
    scope: dict[str, Any],
    receive: Any,
    app: Any
)

Properties

Property Type Description
method str HTTP method
path str Request path
root_path str Root path
scheme str URL scheme
headers Headers Request headers
path_params dict[str, Any] Path parameters
state SimpleNamespace Request state
user Any Authenticated user
query QueryParams Query parameters
cookies Cookies Cookies
client tuple[str, int] \| None Client address
host str Host header
url str Full URL

Methods

body

async def body() -> bytes

Get the request body as bytes.


json

async def json() -> Any

Get the request body as JSON.


text

async def text() -> str

Get the request body as text.


form

async def form() -> dict[str, Any]

Get the request body as form data.


render

async def render(
    template_name: str,
    context: dict[str, Any] | None = None
) -> Any

Render a template using Jinax.


Response

HTTP response object.


Constructor

Response(
    content: bytes | str = b"",
    *,
    status_code: int = 200,
    headers: dict[str, str] | None = None,
    media_type: str | None = None
)

Class Methods

from_value

@classmethod
def from_value(
    cls,
    value: Any
) -> Response

Convert a value to a response.


Response Types


JSONResponse

JSON response.

Constructor

JSONResponse(
    content: Any,
    *,
    status_code: int = 200,
    headers: dict[str, str] | None = None
)

HTMLResponse

HTML response.

Constructor

HTMLResponse(
    content: str,
    *,
    status_code: int = 200,
    headers: dict[str, str] | None = None
)

TextResponse

Plain text response.

Constructor

TextResponse(
    content: str,
    *,
    status_code: int = 200,
    headers: dict[str, str] | None = None
)

RedirectResponse

Redirect response.

Constructor

RedirectResponse(
    url: str,
    status_code: int = 307,
    headers: dict[str, str] | None = None
)

StreamingResponse

Streaming response.

Constructor

StreamingResponse(
    content: AsyncIterator[bytes] | Iterable[bytes],
    *,
    status_code: int = 200,
    headers: dict[str, str] | None = None,
    media_type: str = "application/octet-stream"
)

Headers

HTTP headers dictionary.


Constructor

Headers(
    raw: list[tuple[bytes, bytes]] | None = None
)

Methods

get

get(
    key: str,
    default: Any = None
) -> Any

Get a header value with a default.


get_raw

get_raw(
    key: str
) -> bytes | None

Get a header value as bytes.


to_list

to_list() -> list[tuple[bytes, bytes]]

Convert headers to raw ASGI format.


to_dict

to_dict() -> dict[str, str]

Convert headers to a regular dictionary.


Cookies

HTTP cookies dictionary.


Methods

get

get(
    key: str,
    default: Any = None
) -> Any

Get a cookie value with a default.


set

set(
    key: str,
    value: str,
    *,
    max_age: int | None = None,
    expires: datetime | None = None,
    path: str | None = None,
    domain: str | None = None,
    secure: bool = False,
    httponly: bool = False,
    samesite: str | None = None
) -> None

Set a cookie with options.


delete

delete(
    key: str
) -> None

Delete a cookie.


set_delete

set_delete(
    key: str,
    path: str | None = None
) -> None

Set a cookie to be deleted.


to_dict

to_dict() -> dict[str, str]

Convert cookies to a dictionary.


to_headers

to_headers() -> list[str]

Convert cookies to Set-Cookie headers.


QueryParams

Query parameters dictionary.


Methods

get

get(
    key: str,
    default: Any = None
) -> Any

Get a parameter value.


get_list

get_list(
    key: str
) -> list[str]

Get a parameter as a list.


get_int

get_int(
    key: str,
    default: int | None = None
) -> int | None

Get a parameter as an integer.


get_float

get_float(
    key: str,
    default: float | None = None
) -> float | None

Get a parameter as a float.


get_bool

get_bool(
    key: str,
    default: bool | None = None
) -> bool | None

Get a parameter as a boolean.


get_all

get_all() -> dict[str, list[str]]

Get all parameters as a dictionary of lists.


to_dict

to_dict() -> dict[str, str | list[str]]

Convert to a dictionary.


to_query_string

to_query_string() -> str

Convert to a query string.

Use this capability in a full-stack app

Flaxon serves Python APIs and Teloce interfaces in one project. Keep validation, authorization and privileged operations on the server; components call those endpoints and present their results. Follow the full-stack lessons and Teloce integration reference to connect this capability to pages, components and application modules.