Skip to content

app

Classes#

Functions#

app #

app(
    main: Callable[[Page], Awaitable]
    | Callable[[Page], None],
    before_main: Callable[[Page], Awaitable]
    | Callable[[Page], None] = None,
    proxy_path: str | None = None,
    assets_dir: str | None = None,
    app_name: str | None = None,
    app_short_name: str | None = None,
    app_description: str | None = None,
    web_renderer: WebRenderer = AUTO,
    route_url_strategy: RouteUrlStrategy = PATH,
    no_cdn: bool = False,
    upload_dir: str | None = None,
    upload_endpoint_path: str | None = None,
    max_upload_size: int | None = None,
    secret_key: str | None = None,
    session_timeout_seconds: int = DEFAULT_FLET_SESSION_TIMEOUT,
    oauth_state_timeout_seconds: int = DEFAULT_FLET_OAUTH_STATE_TIMEOUT,
)

Mount all Flet FastAPI handlers in one call.

Parameters:

  • main (Callable[[Page], Awaitable] | Callable[[Page], None]) –

    Application entry point. It is called for newly connected users. Handler (function or coroutine) must have 1 parameter of instance Page.

  • before_main (Callable[[Page], Awaitable] | Callable[[Page], None], default: None ) –

    Called after Page was created, but before calling main.

  • proxy_path (str | None, default: None ) –

    URL prefix when the app is mounted under a proxy.

  • assets_dir (str | None, default: None ) –

    an absolute path to app's assets directory.

  • app_name (str | None, default: None ) –

    PWA application name.

  • app_short_name (str | None, default: None ) –

    PWA application short name.

  • app_description (str | None, default: None ) –

    PWA application description.

  • web_renderer (WebRenderer, default: AUTO ) –

    web renderer defaulting to WebRenderer.AUTO.

  • route_url_strategy (RouteUrlStrategy, default: PATH ) –

    routing URL strategy: path (default) or hash.

  • no_cdn (bool, default: False ) –

    do not load resources from CDN.

  • upload_dir (str | None, default: None ) –

    an absolute path to a directory with uploaded files.

  • upload_endpoint_path (str | None, default: None ) –

    absolute URL of upload endpoint, e.g. /upload.

  • max_upload_size (int | None, default: None ) –

    maximum size of a single upload, bytes. Unlimited if None.

  • secret_key (str | None, default: None ) –

    secret key to sign and verify upload requests.

  • session_timeout_seconds (int, default: DEFAULT_FLET_SESSION_TIMEOUT ) –

    session lifetime, in seconds, after the user disconnected.

  • oauth_state_timeout_seconds (int, default: DEFAULT_FLET_OAUTH_STATE_TIMEOUT ) –

    OAuth state lifetime, in seconds, which is the maximum allowed time between starting OAuth flow and redirecting to OAuth callback URL.