Skip to main content

FletStaticFiles

Serve Flet app static files.

Parameters:

  • assets_dir (Optional[str], default: None) - An absolute path to app's assets directory.
  • app_name (Optional[str], default: None) - PWA application name.
  • app_short_name (Optional[str], default: None) - PWA application short name.
  • app_description (Optional[str], default: None) - PWA application description.
  • web_renderer (WebRenderer, default: WebRenderer.AUTO) - Type of web renderer.
  • route_url_strategy (RouteUrlStrategy, default: RouteUrlStrategy.PATH) - Routing URL strategy.
  • no_cdn (bool, default: False) - Whether not load CanvasKit, Pyodide, and fonts from CDN.
  • websocket_endpoint_path (Optional[str], default: None) - Absolute URL of Flet app WebSocket handler. Defaults to /ws.

Inherits: fastapi.staticfiles.StaticFiles

Properties

Methods

  • lookup_path - Resolve a static file path, with SPA fallback for client-side routes.

Properties

font_manifest_jsoninstance-attribute

indexinstance-attribute

manifest_jsoninstance-attribute

Methods

lookup_path

lookup_path(path: str)

Resolve a static file path, with SPA fallback for client-side routes.

Route-like paths (no extension, or .html) that don't match a file fall back to index.html so the Flutter client can handle routing. Asset-like paths (any other extension) resolve to a real 404.

Parameters:

  • path (str) - Requested path, relative to the mounted static root (e.g. "about", "sample.json").

Returns:

  • tuple[str, Optional[os.stat_result]] - A (full_path, stat_result) tuple. When stat_result is None, Starlette responds with 404.