modal.web_endpoint

def web_endpoint(
    _warn_parentheses_missing=None,
    *,
    method: str = "GET",  # REST method for the created endpoint.
    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,  # Create an endpoint using a custom domain fully-qualified domain name (FQDN).
) -> Callable[[Callable[..., Any]], _PartialFunction]:

Register a basic web endpoint with this application.

This is the simple way to create a web endpoint on Modal. The function behaves as a FastAPI handler and should return a response object to the caller.

Endpoints created with @app.web_endpoint are meant to be simple, single request handlers and automatically have CORS enabled. For more flexibility, use @app.asgi_app.

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