modal.asgi_app

def asgi_app(
    _warn_parentheses_missing=None,
    *,
    label: Optional[str] = None,  # Label for created endpoint. Final subdomain will be <workspace>--<label>.modal.run.
    wait_for_response: bool = True,  # Whether requests should wait for and return the function response.
    custom_domains: Optional[Iterable[str]] = None,  # Deploy this endpoint on a custom domain.
) -> Callable[[Callable[..., Any]], _PartialFunction]:

Decorator for registering an ASGI app with a Modal function.

Asynchronous Server Gateway Interface (ASGI) is a standard for Python synchronous and asynchronous apps, supported by all popular Python web libraries. This is an advanced decorator that gives full flexibility in defining one or more web endpoints on Modal.

Usage:

from typing import Callable

@app.function()
@modal.asgi_app()
def create_asgi() -> Callable:
    ...

To learn how to use Modal with popular web frameworks, see the guide on web endpoints.