view.core.app¶
Primary app implementation.
Functions
|
Decorator for using a single function as an app. |
Classes
|
An application containing an automatic routing mechanism and error handling. |
|
Base view.py application. |
|
Application with a single view function that processes all requests. |
- class App(*, router: Router | None = None)¶
Bases:
BaseAppAn application containing an automatic routing mechanism and error handling.
- asgi() ASGIProtocol¶
Get the ASGI callable for the app.
- connect(path: str, /) Callable[[Callable[[], ResponseLike | Awaitable[ResponseLike]]], Route]¶
Decorator interface for adding a CONNECT route.
- property debug: bool¶
Is the app in debug mode?
If debug mode is enabled, some extra checks and settings are enabled to improve the development experience, at the cost of being slower and less secure.
- delete(path: str, /) Callable[[Callable[[], ResponseLike | Awaitable[ResponseLike]]], Route]¶
Decorator interface for adding a DELETE route.
- property development_mode: bool¶
Whether view.py is in “development mode”. If this is
True, then that means you’re working on contributing to the library itself.This cannot be set from Python. If you’d like to control this behavior, set the
VIEW_DEVMODEenvironment variable to1or0.
- error(status: int | type[HTTPError], /) Callable[[Callable[[], ResponseLike | Awaitable[ResponseLike]]], Callable[[], ResponseLike | Awaitable[ResponseLike]]]¶
Decorator interface for adding an error handler to the app.
- async execute_view(view: ~collections.abc.Callable[[~P], ~view.core.response.Response | str | bytes | ~collections.abc.AsyncGenerator[str | bytes] | ~collections.abc.Generator[str | bytes] | tuple[str | bytes, int] | tuple[str | bytes, int, ~view.core.headers.HTTPHeaders | ~collections.abc.Mapping[str, str] | ~collections.abc.Mapping[bytes, bytes]] | ~collections.abc.Awaitable[~view.core.response.Response | str | bytes | ~collections.abc.AsyncGenerator[str | bytes] | ~collections.abc.Generator[str | bytes] | tuple[str | bytes, int] | tuple[str | bytes, int, ~view.core.headers.HTTPHeaders | ~collections.abc.Mapping[str, str] | ~collections.abc.Mapping[bytes, bytes]]]], *args: ~typing.~P, **kwargs: ~typing.~P) Response¶
- get(path: str, /) Callable[[Callable[[], ResponseLike | Awaitable[ResponseLike]]], Route]¶
Decorator interface for adding a GET route.
- head(path: str, /) Callable[[Callable[[], ResponseLike | Awaitable[ResponseLike]]], Route]¶
Decorator interface for adding a HEAD route.
- logger¶
The logger used by the app.
- options(path: str, /) Callable[[Callable[[], ResponseLike | Awaitable[ResponseLike]]], Route]¶
Decorator interface for adding an OPTIONS route.
- patch(path: str, /) Callable[[Callable[[], ResponseLike | Awaitable[ResponseLike]]], Route]¶
Decorator interface for adding a PATCH route.
- post(path: str, /) Callable[[Callable[[], ResponseLike | Awaitable[ResponseLike]]], Route]¶
Decorator interface for adding a POST route.
- async process_request(request: Request) Response¶
Get the response from the server for a given request.
- put(path: str, /) Callable[[Callable[[], ResponseLike | Awaitable[ResponseLike]]], Route]¶
Decorator interface for adding a PUT route.
- route(path: str, /, *, method: Method) Callable[[Callable[[], ResponseLike | Awaitable[ResponseLike]]], Route]¶
Decorator interface for adding a route to the app.
- run(*, host: str = 'localhost', port: int = 5000, production: bool = False, server_hint: str | None = None) None¶
Run the app.
This is a sort of magic function that’s supposed to “just work”. If finer control over the server settings is desired, explicitly use the server’s API with the app’s
asgi()orwsgi()method.
- run_detached(*, host: str = 'localhost', port: int = 5000, production: bool = False, server_hint: str | None = None) Process¶
Run the app in a separate process. This means that the server is killable.
- trace(path: str, /) Callable[[Callable[[], ResponseLike | Awaitable[ResponseLike]]], Route]¶
Decorator interface for adding a TRACE route.
- wsgi() WSGIProtocol¶
Get the WSGI callable for the app.
- class BaseApp¶
Bases:
ABCBase view.py application.
- asgi() ASGIProtocol¶
Get the ASGI callable for the app.
- property debug: bool¶
Is the app in debug mode?
If debug mode is enabled, some extra checks and settings are enabled to improve the development experience, at the cost of being slower and less secure.
- property development_mode: bool¶
Whether view.py is in “development mode”. If this is
True, then that means you’re working on contributing to the library itself.This cannot be set from Python. If you’d like to control this behavior, set the
VIEW_DEVMODEenvironment variable to1or0.
- async execute_view(view: ~collections.abc.Callable[[~P], ~view.core.response.Response | str | bytes | ~collections.abc.AsyncGenerator[str | bytes] | ~collections.abc.Generator[str | bytes] | tuple[str | bytes, int] | tuple[str | bytes, int, ~view.core.headers.HTTPHeaders | ~collections.abc.Mapping[str, str] | ~collections.abc.Mapping[bytes, bytes]] | ~collections.abc.Awaitable[~view.core.response.Response | str | bytes | ~collections.abc.AsyncGenerator[str | bytes] | ~collections.abc.Generator[str | bytes] | tuple[str | bytes, int] | tuple[str | bytes, int, ~view.core.headers.HTTPHeaders | ~collections.abc.Mapping[str, str] | ~collections.abc.Mapping[bytes, bytes]]]], *args: ~typing.~P, **kwargs: ~typing.~P) Response¶
- logger¶
The logger used by the app.
- abstract async process_request(request: Request) Response¶
Get the response from the server for a given request.
- run(*, host: str = 'localhost', port: int = 5000, production: bool = False, server_hint: str | None = None) None¶
Run the app.
This is a sort of magic function that’s supposed to “just work”. If finer control over the server settings is desired, explicitly use the server’s API with the app’s
asgi()orwsgi()method.
- run_detached(*, host: str = 'localhost', port: int = 5000, production: bool = False, server_hint: str | None = None) Process¶
Run the app in a separate process. This means that the server is killable.
- wsgi() WSGIProtocol¶
Get the WSGI callable for the app.
- class SingleViewApp(view: Callable[[Request], Response | str | bytes | AsyncGenerator[str | bytes] | Generator[str | bytes] | tuple[str | bytes, int] | tuple[str | bytes, int, HTTPHeaders | Mapping[str, str] | Mapping[bytes, bytes]] | Awaitable[Response | str | bytes | AsyncGenerator[str | bytes] | Generator[str | bytes] | tuple[str | bytes, int] | tuple[str | bytes, int, HTTPHeaders | Mapping[str, str] | Mapping[bytes, bytes]]]])¶
Bases:
BaseAppApplication with a single view function that processes all requests.
- asgi() ASGIProtocol¶
Get the ASGI callable for the app.
- property debug: bool¶
Is the app in debug mode?
If debug mode is enabled, some extra checks and settings are enabled to improve the development experience, at the cost of being slower and less secure.
- property development_mode: bool¶
Whether view.py is in “development mode”. If this is
True, then that means you’re working on contributing to the library itself.This cannot be set from Python. If you’d like to control this behavior, set the
VIEW_DEVMODEenvironment variable to1or0.
- async execute_view(view: ~collections.abc.Callable[[~P], ~view.core.response.Response | str | bytes | ~collections.abc.AsyncGenerator[str | bytes] | ~collections.abc.Generator[str | bytes] | tuple[str | bytes, int] | tuple[str | bytes, int, ~view.core.headers.HTTPHeaders | ~collections.abc.Mapping[str, str] | ~collections.abc.Mapping[bytes, bytes]] | ~collections.abc.Awaitable[~view.core.response.Response | str | bytes | ~collections.abc.AsyncGenerator[str | bytes] | ~collections.abc.Generator[str | bytes] | tuple[str | bytes, int] | tuple[str | bytes, int, ~view.core.headers.HTTPHeaders | ~collections.abc.Mapping[str, str] | ~collections.abc.Mapping[bytes, bytes]]]], *args: ~typing.~P, **kwargs: ~typing.~P) Response¶
- logger¶
The logger used by the app.
- async process_request(request: Request) Response¶
Get the response from the server for a given request.
- run(*, host: str = 'localhost', port: int = 5000, production: bool = False, server_hint: str | None = None) None¶
Run the app.
This is a sort of magic function that’s supposed to “just work”. If finer control over the server settings is desired, explicitly use the server’s API with the app’s
asgi()orwsgi()method.
- run_detached(*, host: str = 'localhost', port: int = 5000, production: bool = False, server_hint: str | None = None) Process¶
Run the app in a separate process. This means that the server is killable.
- wsgi() WSGIProtocol¶
Get the WSGI callable for the app.
- as_app(view: Callable[[Request], Response | str | bytes | AsyncGenerator[str | bytes] | Generator[str | bytes] | tuple[str | bytes, int] | tuple[str | bytes, int, HTTPHeaders | Mapping[str, str] | Mapping[bytes, bytes]] | Awaitable[Response | str | bytes | AsyncGenerator[str | bytes] | Generator[str | bytes] | tuple[str | bytes, int] | tuple[str | bytes, int, HTTPHeaders | Mapping[str, str] | Mapping[bytes, bytes]]]], /) SingleViewApp¶
Decorator for using a single function as an app.