view.core.app¶
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.
- connect(path: str, /) Callable[[Callable[[], ResponseLike | Awaitable[ResponseLike]]], Route]¶
Decorator interface for adding a CONNECT route.
- delete(path: str, /) Callable[[Callable[[], ResponseLike | Awaitable[ResponseLike]]], Route]¶
Decorator interface for adding a DELETE route.
- error(status: int | type[HTTPError], /) Callable[[Callable[[], ResponseLike | Awaitable[ResponseLike]]], Callable[[], ResponseLike | Awaitable[ResponseLike]]]¶
Decorator interface for adding an error handler to the app.
- 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.
- 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.
- 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.
- 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.
- 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.