# quart.app module

class quart.app.Quart(import_name, static_url_path=None, static_folder='static', static_host=None, host_matching=False, subdomain_matching=False, template_folder='templates', instance_path=None, instance_relative_config=False, root_path=None)

  Bases: `App`

  The web framework class, handles requests and returns responses.

  The primary method from a serving viewpoint is `handle_request()`, from an application viewpoint all the other methods are vital.

  This can be extended in many ways, with most methods designed with this in mind. Additionally any of the classes listed as attributes can be replaced.

  Parameters:

    - import_name (str)

    - static_url_path (str | None)

    - static_folder (str | None)

    - static_host (str | None)

    - host_matching (bool)

    - subdomain_matching (bool)

    - template_folder (str | None)

    - instance_path (str | None)

    - instance_relative_config (bool)

    - root_path (str | None)

  aborter_class

    The class to use to raise HTTP error via the abort helper function.

  app_ctx_globals_class

    The class to use for the `g` object

  asgi_http_class

    The class to use to handle the ASGI HTTP protocol.

    Type:

      type[ASGIHTTPProtocol]

  asgi_lifespan_class

    The class to use to handle the ASGI lifespan protocol.

    Type:

      type[ASGILifespanProtocol]

  asgi_websocket_class

    The class to use to handle the ASGI websocket protocol.

    Type:

      type[ASGIWebsocketProtocol]

  config_class

    The class to use for the configuration.

  env

    The name of the environment the app is running on.

  event_class

    The class to use to signal an event in an async manner.

  debug

    Wrapper around configuration DEBUG value, in many places this will result in more output if True. If unset, debug mode will be activated if environ is set to ‘development’.

  jinja_environment

    The class to use for the jinja environment.

  jinja_options

    The default options to set when creating the jinja environment.

  permanent_session_lifetime

    Wrapper around configuration PERMANENT_SESSION_LIFETIME value. Specifies how long the session data should survive.

  request_class

    The class to use for requests.

  response_class

    The class to user for responses.

  secret_key

    Warpper around configuration SECRET_KEY value. The app secret for signing sessions.

  session_interface

    The class to use as the session interface.

  shutdown_event

    This event is set when the app starts to shutdown allowing waiting tasks to know when to stop.

    Type:

      Event

  url_map_class

    The class to map rules to endpoints.

  url_rule_class

    The class to use for URL rules.

  websocket_class

    The class to use for websockets.

  shutdown_event: Event
  aborter_class

    alias of `Aborter`

  app_ctx_globals_class

    alias of `_AppCtxGlobals`

  asgi_http_class

    alias of `ASGIHTTPConnection`

  asgi_lifespan_class

    alias of `ASGILifespan`

  asgi_websocket_class

    alias of `ASGIWebsocketConnection`

  config_class

    alias of `Config`

  event_class

    alias of `Event`

  jinja_environment

    alias of `Environment`

  lock_class

    alias of `Lock`

  request_class

    alias of `Request`

  response_class

    alias of `Response`

  session_interface = <quart.sessions.SecureCookieSessionInterface object>
  test_app_class

    alias of `TestApp`

  test_client_class

    alias of `QuartClient`

  test_cli_runner_class

    alias of `QuartCliRunner`

  url_map_class

    alias of `QuartMap`

  url_rule_class

    alias of `QuartRule`

  websocket_class

    alias of `Websocket`

  default_config: dict[str, t.Any] = {'APPLICATION_ROOT': '/', 'BACKGROUND_TASK_SHUTDOWN_TIMEOUT': 5, 'BODY_TIMEOUT': 60, 'DEBUG': None, 'ENV': None, 'EXPLAIN_TEMPLATE_LOADING': False, 'MAX_CONTENT_LENGTH': 16777216, 'MAX_COOKIE_SIZE': 4093, 'MAX_FORM_MEMORY_SIZE': 500000, 'MAX_FORM_PARTS': 1000, 'PERMANENT_SESSION_LIFETIME': datetime.timedelta(days=31), 'PREFER_SECURE_URLS': False, 'PRESERVE_CONTEXT_ON_EXCEPTION': None, 'PROPAGATE_EXCEPTIONS': None, 'PROVIDE_AUTOMATIC_OPTIONS': True, 'RESPONSE_TIMEOUT': 60, 'SECRET_KEY': None, 'SEND_FILE_MAX_AGE_DEFAULT': datetime.timedelta(seconds=43200), 'SERVER_NAME': None, 'SESSION_COOKIE_DOMAIN': None, 'SESSION_COOKIE_HTTPONLY': True, 'SESSION_COOKIE_NAME': 'session', 'SESSION_COOKIE_PATH': None, 'SESSION_COOKIE_SAMESITE': None, 'SESSION_COOKIE_SECURE': False, 'SESSION_REFRESH_EACH_REQUEST': True, 'TEMPLATES_AUTO_RELOAD': None, 'TESTING': False, 'TRAP_BAD_REQUEST_ERRORS': None, 'TRAP_HTTP_EXCEPTIONS': False}
  get_send_file_max_age(filename)

    Used by `send_file()` to determine the `max_age` cache value for a given file path if it wasn’t passed.

    By default, this returns `SEND_FILE_MAX_AGE_DEFAULT` from the configuration of `current_app`. This defaults to `None`, which tells the browser to use conditional requests instead of a timed cache, which is usually preferable.

    Note this is a duplicate of the same method in the Quart class.

    Parameters:

      filename (str | None)

    Return type:

      int | None

  async send_static_file(filename)
    Parameters:

      filename (str)

    Return type:

      Response

  async open_resource(path, mode='rb')

    Open a file for reading.

    Use as

        async with await app.open_resource(path) as file_:
            await file_.read()

    Parameters:

      - path (bytes | str | PathLike)

      - mode (str)

    Return type:

      AiofilesContextManager

  async open_instance_resource(path, mode='rb')

    Open a file for reading.

    Use as

        async with await app.open_instance_resource(path) as file_:
            await file_.read()

    Parameters:

      - path (bytes | str | PathLike)

      - mode (str)

    Return type:

      AiofilesContextManager

  create_jinja_environment()

    Create and return the jinja environment.

    This will create the environment based on the `jinja_options` and configuration settings. The environment will include the Quart globals by default.

    Return type:

      Environment

  async update_template_context(context)

    Update the provided template context.

    This adds additional context from the various template context processors.

    Parameters:

      context (dict) – The context to update (mutate).

    Return type:

      None

  before_serving(func)

    Add a before serving function.

    This will allow the function provided to be called once before anything is served (before any byte is received).

    This is designed to be used as a decorator, if used to decorate a synchronous function, the function will be wrapped in `run_sync()` and run in a thread executor (with the wrapped function returned). An example usage,

        @app.before_serving
        async def func():
            ...

    Parameters:

      func (T_before_serving) – The function itself.

    Return type:

      T_before_serving

  while_serving(func)

    Add a while serving generator function.

    This will allow the generator provided to be invoked at startup and then again at shutdown.

    This is designed to be used as a decorator. An example usage,

        @app.while_serving
        async def func():
            ...  # Startup
            yield
            ...  # Shutdown

    Parameters:

      func (T_while_serving) – The function itself.

    Return type:

      T_while_serving

  after_serving(func)

    Add a after serving function.

    This will allow the function provided to be called once after anything is served (after last byte is sent).

    This is designed to be used as a decorator, if used to decorate a synchronous function, the function will be wrapped in `run_sync()` and run in a thread executor (with the wrapped function returned). An example usage,

        @app.after_serving
        async def func():
            ...

    Parameters:

      func (T_after_serving) – The function itself.

    Return type:

      T_after_serving

  create_url_adapter(request)

    Create and return a URL adapter.

    This will create the adapter based on the request if present otherwise the app configuration.

    Parameters:

      request (BaseRequestWebsocket | None)

    Return type:

      MapAdapter | None

  websocket(rule, **options)

    Add a websocket to the application.

    This is designed to be used as a decorator, if used to decorate a synchronous function, the function will be wrapped in `run_sync()` and run in a thread executor (with the wrapped function returned). An example usage,

        @app.websocket('/')
        async def websocket_route():
            ...

    Parameters:

      - rule (str) – The path to route on, should start with a `/`.

      - endpoint – Optional endpoint name, if not present the function name is used.

      - defaults –

        A dictionary of variables to provide automatically, use to provide a simpler default path for a route, e.g. to allow for `/book` rather than `/book/0`,

            @app.websocket('/book', defaults={'page': 0})
            @app.websocket('/book/<int:page>')
            def book(page):
                ...

      - host – The full host name for this route (should include subdomain if needed) - cannot be used with subdomain.

      - subdomain – A subdomain for this specific route.

      - strict_slashes – Strictly match the trailing slash present in the path. Will redirect a leaf (no slash) to a branch (with slash).

      - options (Any)

    Return type:

      Callable[[T_websocket], T_websocket]

  add_websocket(rule, endpoint=None, view_func=None, **options)

    Add a websocket url rule to the application.

    This is designed to be used on the application directly. An example usage,

        def websocket_route():
            ...

        app.add_websocket('/', websocket_route)

    Parameters:

      - rule (str) – The path to route on, should start with a `/`.

      - endpoint (str | None) – Optional endpoint name, if not present the function name is used.

      - view_func (Callable[[...], Response | Response | bytes | str | Mapping[str, Any] | list[Any] | Iterator[bytes] | Iterator[str] | tuple[Response | Response | bytes | str | Mapping[str, Any] | list[Any] | Iterator[bytes] | Iterator[str], Headers | Mapping[str, str | list[str] | tuple[str, ...]] | Sequence[tuple[str, str | list[str] | tuple[str, ...]]]] | tuple[Response | Response | bytes | str | Mapping[str, Any] | list[Any] | Iterator[bytes] | Iterator[str], int] | tuple[Response | Response | bytes | str | Mapping[str, Any] | list[Any] | Iterator[bytes] | Iterator[str], int, Headers | Mapping[str, str | list[str] | tuple[str, ...]] | Sequence[tuple[str, str | list[str] | tuple[str, ...]]]] | None] | Callable[[...], Awaitable[Response | Response | bytes | str | Mapping[str, Any] | list[Any] | Iterator[bytes] | Iterator[str] | tuple[Response | Response | bytes | str | Mapping[str, Any] | list[Any] | Iterator[bytes] | Iterator[str], Headers | Mapping[str, str | list[str] | tuple[str, ...]] | Sequence[tuple[str, str | list[str] | tuple[str, ...]]]] | tuple[Response | Response | bytes | str | Mapping[str, Any] | list[Any] | Iterator[bytes] | Iterator[str], int] | tuple[Response | Response | bytes | str | Mapping[str, Any] | list[Any] | Iterator[bytes] | Iterator[str], int, Headers | Mapping[str, str | list[str] | tuple[str, ...]] | Sequence[tuple[str, str | list[str] | tuple[str, ...]]]] | None]] | None) – Callable that returns a response.

      - defaults –

        A dictionary of variables to provide automatically, use to provide a simpler default path for a route, e.g. to allow for `/book` rather than `/book/0`,

            @app.websocket('/book', defaults={'page': 0})
            @app.websocket('/book/<int:page>')
            def book(page):
                ...

      - host – The full host name for this route (should include subdomain if needed) - cannot be used with subdomain.

      - subdomain – A subdomain for this specific route.

      - strict_slashes – Strictly match the trailing slash present in the path. Will redirect a leaf (no slash) to a branch (with slash).

      - options (Any)

    Return type:

      None

  url_for(endpoint, *, _anchor=None, _external=None, _method=None, _scheme=None, **values)

    Return the url for a specific endpoint.

    This is most useful in templates and redirects to create a URL that can be used in the browser.

    Parameters:

      - endpoint (str) – The endpoint to build a url for, if prefixed with `.` it targets endpoint’s in the current blueprint.

      - _anchor (str | None) – Additional anchor text to append (i.e. #text).

      - _external (bool | None) – Return an absolute url for external (to app) usage.

      - _method (str | None) – The method to consider alongside the endpoint.

      - _scheme (str | None) – A specific scheme to use.

      - values (Any) – The values to build into the URL, as specified in the endpoint rule.

    Return type:

      str

  make_shell_context()

    Create a context for interactive shell usage.

    The `shell_context_processors` can be used to add additional context.

    Return type:

      dict

  run(host=None, port=None, debug=None, use_reloader=True, loop=None, ca_certs=None, certfile=None, keyfile=None, **kwargs)

    Run this application.

    This is best used for development only, see Hypercorn for production servers.

    Parameters:

      - host (str | None) – Hostname to listen on. By default this is loopback only, use 0.0.0.0 to have the server listen externally.

      - port (int | None) – Port number to listen on.

      - debug (bool | None) – If set enable (or disable) debug mode and debug output.

      - use_reloader (bool) – Automatically reload on code changes.

      - loop (AbstractEventLoop | None) – Asyncio loop to create the server in, if None, take default one. If specified it is the caller’s responsibility to close and cleanup the loop.

      - ca_certs (str | None) – Path to the SSL CA certificate file.

      - certfile (str | None) – Path to the SSL certificate file.

      - keyfile (str | None) – Path to the SSL key file.

      - kwargs (Any)

    Return type:

      None

  run_task(host='127.0.0.1', port=5000, debug=None, ca_certs=None, certfile=None, keyfile=None, shutdown_trigger=None)

    Return a task that when awaited runs this application.

    This is best used for development only, see Hypercorn for production servers.

    Parameters:

      - host (str) – Hostname to listen on. By default this is loopback only, use 0.0.0.0 to have the server listen externally.

      - port (int) – Port number to listen on.

      - debug (bool | None) – If set enable (or disable) debug mode and debug output.

      - ca_certs (str | None) – Path to the SSL CA certificate file.

      - certfile (str | None) – Path to the SSL certificate file.

      - keyfile (str | None) – Path to the SSL key file.

      - shutdown_trigger (Callable[[...], Awaitable[None]] | None)

    Return type:

      Coroutine[None, None, None]

  test_client(use_cookies=True, **kwargs)

    Creates and returns a test client.

    Parameters:

      - use_cookies (bool)

      - kwargs (Any)

    Return type:

      TestClientProtocol

  test_cli_runner(**kwargs)

    Creates and returns a CLI test runner.

    Parameters:

      kwargs (Any)

    Return type:

      QuartCliRunner

  before_websocket(func)

    Add a before websocket function.

    This is designed to be used as a decorator, if used to decorate a synchronous function, the function will be wrapped in `run_sync()` and run in a thread executor (with the wrapped function returned). An example usage,

        @app.before_websocket
        async def func():
            ...

    Parameters:

      func (T_before_websocket) – The before websocket function itself.

    Return type:

      T_before_websocket

  after_websocket(func)

    Add an after websocket function.

    This is designed to be used as a decorator, if used to decorate a synchronous function, the function will be wrapped in `run_sync()` and run in a thread executor (with the wrapped function returned). An example usage,

        @app.after_websocket
        async def func(response):
            return response

    Parameters:

      func (T_after_websocket) – The after websocket function itself.

    Return type:

      T_after_websocket

  teardown_websocket(func)

    Add a teardown websocket function. This is designed to be used as a decorator, if used to decorate a synchronous function, the function will be wrapped in `run_sync()` and run in a thread executor (with the wrapped function returned). An example usage, .. code-block:: python

    > @app.teardown_websocket async def func():

    > > …

    Parameters:

      func (T_teardown) – The teardown websocket function itself.

    Return type:

      T_teardown

  async handle_http_exception(error)

    Handle a HTTPException subclass error.

    This will attempt to find a handler for the error and if fails will fall back to the error response.

    Parameters:

      error (HTTPException)

    Return type:

      HTTPException | Response | Response | bytes | str | Mapping[str, Any] | list[Any] | Iterator[bytes] | Iterator[str] | tuple[Response | Response | bytes | str | Mapping[str, Any] | list[Any] | Iterator[bytes] | Iterator[str], Headers | Mapping[str, str | list[str] | tuple[str, …]] | Sequence[tuple[str, str | list[str] | tuple[str, …]]]] | tuple[Response | Response | bytes | str | Mapping[str, Any] | list[Any] | Iterator[bytes] | Iterator[str], int] | tuple[Response | Response | bytes | str | Mapping[str, Any] | list[Any] | Iterator[bytes] | Iterator[str], int, Headers | Mapping[str, str | list[str] | tuple[str, …]] | Sequence[tuple[str, str | list[str] | tuple[str, …]]]]

  async handle_user_exception(error)

    Handle an exception that has been raised.

    This should forward `HTTPException` to `handle_http_exception()`, then attempt to handle the error. If it cannot it should reraise the error.

    Parameters:

      error (Exception)

    Return type:

      HTTPException | Response | Response | bytes | str | Mapping[str, Any] | list[Any] | Iterator[bytes] | Iterator[str] | tuple[Response | Response | bytes | str | Mapping[str, Any] | list[Any] | Iterator[bytes] | Iterator[str], Headers | Mapping[str, str | list[str] | tuple[str, …]] | Sequence[tuple[str, str | list[str] | tuple[str, …]]]] | tuple[Response | Response | bytes | str | Mapping[str, Any] | list[Any] | Iterator[bytes] | Iterator[str], int] | tuple[Response | Response | bytes | str | Mapping[str, Any] | list[Any] | Iterator[bytes] | Iterator[str], int, Headers | Mapping[str, str | list[str] | tuple[str, …]] | Sequence[tuple[str, str | list[str] | tuple[str, …]]]]

  async handle_exception(error)

    Handle an uncaught exception.

    By default this switches the error response to a 500 internal server error.

    Parameters:

      error (Exception)

    Return type:

      Response | Response

  async handle_websocket_exception(error)

    Handle an uncaught exception.

    By default this logs the exception and then re-raises it.

    Parameters:

      error (Exception)

    Return type:

      Response | Response | None

  log_exception(exception_info)

    Log a exception to the `logger`.

    By default this is only invoked for unhandled exceptions.

    Parameters:

      exception_info (tuple[type, BaseException, TracebackType] | tuple[None, None, None])

    Return type:

      None

  ensure_async(func: Callable[[P], Awaitable[T]]) → Callable[[P], Awaitable[T]]
  ensure_async(func: Callable[[P], T]) → Callable[[P], Awaitable[T]]

    Ensure that the returned func is async and calls the func.

    Added in version 0.11.

    Override if you wish to change how synchronous functions are run. Before Quart 0.11 this did not run the synchronous code in an executor.

  sync_to_async(func)

    Return a async function that will run the synchronous function func.

    This can be used as so,:

        result = await app.sync_to_async(func)(*args, **kwargs)

    Override this method to change how the app converts sync code to be asynchronously callable.

    Parameters:

      func (Callable[[~P], T])

    Return type:

      Callable[[~P], Awaitable[T]]

  async do_teardown_request(exc, request_context=None)

    Teardown the request, calling the teardown functions.

    Parameters:

      - exc (BaseException | None) – Any exception not handled that has caused the request to teardown.

      - request_context (RequestContext | None) – The request context, optional as Flask omits this argument.

    Return type:

      None

  async do_teardown_websocket(exc, websocket_context=None)

    Teardown the websocket, calling the teardown functions.

    Parameters:

      - exc (BaseException | None) – Any exception not handled that has caused the websocket to teardown.

      - websocket_context (WebsocketContext | None) – The websocket context, optional as Flask omits this argument.

    Return type:

      None

  async do_teardown_appcontext(exc)

    Teardown the app (context), calling the teardown functions.

    Parameters:

      exc (BaseException | None)

    Return type:

      None

  app_context()

    Create and return an app context.

    This is best used within a context, i.e.

        async with app.app_context():
            ...

    Return type:

      AppContext

  request_context(request)

    Create and return a request context.

    Use the `test_request_context()` whilst testing. This is best used within a context, i.e.

        async with app.request_context(request):
            ...

    Parameters:

      request (Request) – A request to build a context around.

    Return type:

      RequestContext

  websocket_context(websocket)

    Create and return a websocket context.

    Use the `test_websocket_context()` whilst testing. This is best used within a context, i.e.

        async with app.websocket_context(websocket):
            ...

    Parameters:

      websocket (Websocket) – A websocket to build a context around.

    Return type:

      WebsocketContext

  test_app()
    Return type:

      TestAppProtocol

  test_request_context(path, *, method='GET', headers=None, query_string=None, scheme='http', send_push_promise=no_op_push, data=None, form=None, json=sentinel, root_path='', http_version='1.1', scope_base=None, auth=None, subdomain=None)

    Create a request context for testing purposes.

    This is best used for testing code within request contexts. It is a simplified wrapper of `request_context()`. It is best used in a with block, i.e.

        async with app.test_request_context("/", method="GET"):
            ...

    Parameters:

      - path (str) – Request path.

      - method (str) – HTTP verb

      - headers (dict | Headers | None) – Headers to include in the request.

      - query_string (dict | None) – To send as a dictionary, alternatively the query_string can be determined from the path.

      - scheme (str) – Scheme for the request, default http.

      - send_push_promise (Callable[[str, Headers], Awaitable[None]])

      - data (AnyStr | None)

      - form (dict | None)

      - json (Any)

      - root_path (str)

      - http_version (str)

      - scope_base (dict | None)

      - auth (Authorization | tuple[str, str] | None)

      - subdomain (str | None)

    Return type:

      RequestContext

  add_background_task(func, *args, **kwargs)
    Parameters:

      - func (Callable)

      - args (Any)

      - kwargs (Any)

    Return type:

      None

  async handle_background_exception(error)
    Parameters:

      error (Exception)

    Return type:

      None

  async make_default_options_response()

    This is the default route function for OPTIONS requests.

    Return type:

      Response

  async make_response(result)

    Make a Response from the result of the route handler.

    The result itself can either be:

      - A Response object (or subclass).

      - A tuple of a ResponseValue and a header dictionary.

      - A tuple of a ResponseValue, status code and a header dictionary.

    A ResponseValue is either a Response object (or subclass) or a str.

    Parameters:

      result (Response | Response | bytes | str | Mapping[str, Any] | list[Any] | Iterator[bytes] | Iterator[str] | tuple[Response | Response | bytes | str | Mapping[str, Any] | list[Any] | Iterator[bytes] | Iterator[str], Headers | Mapping[str, str | list[str] | tuple[str, ...]] | Sequence[tuple[str, str | list[str] | tuple[str, ...]]]] | tuple[Response | Response | bytes | str | Mapping[str, Any] | list[Any] | Iterator[bytes] | Iterator[str], int] | tuple[Response | Response | bytes | str | Mapping[str, Any] | list[Any] | Iterator[bytes] | Iterator[str], int, Headers | Mapping[str, str | list[str] | tuple[str, ...]] | Sequence[tuple[str, str | list[str] | tuple[str, ...]]]] | HTTPException)

    Return type:

      Response | Response

  async handle_request(request)
    Parameters:

      request (Request)

    Return type:

      Response | Response

  async handle_websocket(websocket)
    Parameters:

      websocket (Websocket)

    Return type:

      Response | Response | None

  async full_dispatch_request(request_context=None)

    Adds pre and post processing to the request dispatching.

    Parameters:

      request_context (RequestContext | None) – The request context, optional as Flask omits this argument.

    Return type:

      Response | Response

  async full_dispatch_websocket(websocket_context=None)

    Adds pre and post processing to the websocket dispatching.

    Parameters:

      websocket_context (WebsocketContext | None) – The websocket context, optional to match the Flask convention.

    Return type:

      Response | Response | None

  async preprocess_request(request_context=None)

    Preprocess the request i.e. call before_request functions.

    Parameters:

      request_context (RequestContext | None) – The request context, optional as Flask omits this argument.

    Return type:

      Response | Response | bytes | str | Mapping[str, Any] | list[Any] | Iterator[bytes] | Iterator[str] | tuple[Response | Response | bytes | str | Mapping[str, Any] | list[Any] | Iterator[bytes] | Iterator[str], Headers | Mapping[str, str | list[str] | tuple[str, …]] | Sequence[tuple[str, str | list[str] | tuple[str, …]]]] | tuple[Response | Response | bytes | str | Mapping[str, Any] | list[Any] | Iterator[bytes] | Iterator[str], int] | tuple[Response | Response | bytes | str | Mapping[str, Any] | list[Any] | Iterator[bytes] | Iterator[str], int, Headers | Mapping[str, str | list[str] | tuple[str, …]] | Sequence[tuple[str, str | list[str] | tuple[str, …]]]] | None

  async preprocess_websocket(websocket_context=None)

    Preprocess the websocket i.e. call before_websocket functions.

    Parameters:

      websocket_context (WebsocketContext | None) – The websocket context, optional as Flask omits this argument.

    Return type:

      Response | Response | bytes | str | Mapping[str, Any] | list[Any] | Iterator[bytes] | Iterator[str] | tuple[Response | Response | bytes | str | Mapping[str, Any] | list[Any] | Iterator[bytes] | Iterator[str], Headers | Mapping[str, str | list[str] | tuple[str, …]] | Sequence[tuple[str, str | list[str] | tuple[str, …]]]] | tuple[Response | Response | bytes | str | Mapping[str, Any] | list[Any] | Iterator[bytes] | Iterator[str], int] | tuple[Response | Response | bytes | str | Mapping[str, Any] | list[Any] | Iterator[bytes] | Iterator[str], int, Headers | Mapping[str, str | list[str] | tuple[str, …]] | Sequence[tuple[str, str | list[str] | tuple[str, …]]]] | None

  raise_routing_exception(request)
    Parameters:

      request (BaseRequestWebsocket)

    Return type:

      NoReturn

  async dispatch_request(request_context=None)

    Dispatch the request to the view function.

    Parameters:

      request_context (RequestContext | None) – The request context, optional as Flask omits this argument.

    Return type:

      Response | Response | bytes | str | Mapping[str, Any] | list[Any] | Iterator[bytes] | Iterator[str] | tuple[Response | Response | bytes | str | Mapping[str, Any] | list[Any] | Iterator[bytes] | Iterator[str], Headers | Mapping[str, str | list[str] | tuple[str, …]] | Sequence[tuple[str, str | list[str] | tuple[str, …]]]] | tuple[Response | Response | bytes | str | Mapping[str, Any] | list[Any] | Iterator[bytes] | Iterator[str], int] | tuple[Response | Response | bytes | str | Mapping[str, Any] | list[Any] | Iterator[bytes] | Iterator[str], int, Headers | Mapping[str, str | list[str] | tuple[str, …]] | Sequence[tuple[str, str | list[str] | tuple[str, …]]]]

  async dispatch_websocket(websocket_context=None)

    Dispatch the websocket to the view function.

    Parameters:

      websocket_context (WebsocketContext | None) – The websocket context, optional to match the Flask convention.

    Return type:

      Response | Response | bytes | str | Mapping[str, Any] | list[Any] | Iterator[bytes] | Iterator[str] | tuple[Response | Response | bytes | str | Mapping[str, Any] | list[Any] | Iterator[bytes] | Iterator[str], Headers | Mapping[str, str | list[str] | tuple[str, …]] | Sequence[tuple[str, str | list[str] | tuple[str, …]]]] | tuple[Response | Response | bytes | str | Mapping[str, Any] | list[Any] | Iterator[bytes] | Iterator[str], int] | tuple[Response | Response | bytes | str | Mapping[str, Any] | list[Any] | Iterator[bytes] | Iterator[str], int, Headers | Mapping[str, str | list[str] | tuple[str, …]] | Sequence[tuple[str, str | list[str] | tuple[str, …]]]] | None

  async finalize_request(result, request_context=None, from_error_handler=False)

    Turns the view response return value into a response.

    Parameters:

      - result (Response | Response | bytes | str | Mapping[str, Any] | list[Any] | Iterator[bytes] | Iterator[str] | tuple[Response | Response | bytes | str | Mapping[str, Any] | list[Any] | Iterator[bytes] | Iterator[str], Headers | Mapping[str, str | list[str] | tuple[str, ...]] | Sequence[tuple[str, str | list[str] | tuple[str, ...]]]] | tuple[Response | Response | bytes | str | Mapping[str, Any] | list[Any] | Iterator[bytes] | Iterator[str], int] | tuple[Response | Response | bytes | str | Mapping[str, Any] | list[Any] | Iterator[bytes] | Iterator[str], int, Headers | Mapping[str, str | list[str] | tuple[str, ...]] | Sequence[tuple[str, str | list[str] | tuple[str, ...]]]] | HTTPException) – The result of the request to finalize into a response.

      - request_context (RequestContext | None) – The request context, optional as Flask omits this argument.

      - from_error_handler (bool)

    Return type:

      Response | Response

  async finalize_websocket(result, websocket_context=None, from_error_handler=False)

    Turns the view response return value into a response.

    Parameters:

      - result (Response | Response | bytes | str | Mapping[str, Any] | list[Any] | Iterator[bytes] | Iterator[str] | tuple[Response | Response | bytes | str | Mapping[str, Any] | list[Any] | Iterator[bytes] | Iterator[str], Headers | Mapping[str, str | list[str] | tuple[str, ...]] | Sequence[tuple[str, str | list[str] | tuple[str, ...]]]] | tuple[Response | Response | bytes | str | Mapping[str, Any] | list[Any] | Iterator[bytes] | Iterator[str], int] | tuple[Response | Response | bytes | str | Mapping[str, Any] | list[Any] | Iterator[bytes] | Iterator[str], int, Headers | Mapping[str, str | list[str] | tuple[str, ...]] | Sequence[tuple[str, str | list[str] | tuple[str, ...]]]] | HTTPException) – The result of the websocket to finalize into a response.

      - websocket_context (WebsocketContext | None) – The websocket context, optional as Flask omits this argument.

      - from_error_handler (bool)

    Return type:

      Response | Response | None

  async process_response(response, request_context=None)

    Postprocess the request acting on the response.

    Parameters:

      - response (Response | Response) – The response after the request is finalized.

      - request_context (RequestContext | None) – The request context, optional as Flask omits this argument.

    Return type:

      Response | Response

  async postprocess_websocket(response, websocket_context=None)

    Postprocess the websocket acting on the response.

    Parameters:

      - response (Response | Response | None) – The response after the websocket is finalized.

      - websocket_context (WebsocketContext | None) – The websocket context, optional as Flask omits this argument.

    Return type:

      Response | Response

  async asgi_app(scope, receive, send)

    This handles ASGI calls, it can be wrapped in middleware.

    When using middleware with Quart it is preferable to wrap this method rather than the app itself. This is to ensure that the app is an instance of this class - which allows the quart cli to work correctly. To use this feature simply do,

        app.asgi_app = middleware(app.asgi_app)

    Parameters:

      - scope (HTTPScope | WebsocketScope | LifespanScope)

      - receive (Callable[[], Awaitable[HTTPRequestEvent | HTTPDisconnectEvent | WebsocketConnectEvent | WebsocketReceiveEvent | WebsocketDisconnectEvent | LifespanStartupEvent | LifespanShutdownEvent]])

      - send (Callable[[HTTPResponseStartEvent | HTTPResponseBodyEvent | HTTPResponseTrailersEvent | HTTPServerPushEvent | HTTPEarlyHintEvent | HTTPDisconnectEvent | WebsocketAcceptEvent | WebsocketSendEvent | WebsocketResponseStartEvent | WebsocketResponseBodyEvent | WebsocketCloseEvent | LifespanStartupCompleteEvent | LifespanStartupFailedEvent | LifespanShutdownCompleteEvent | LifespanShutdownFailedEvent], Awaitable[None]])

    Return type:

      None

  async startup()
    Return type:

      None

  async shutdown()
    Return type:

      None