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.
    custom_domains: Optional[Iterable[str]] = None,  # Deploy this endpoint on a custom domain.
    wait_for_response: bool = True,  # DEPRECATED: this must always be True now
) -> 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.