Skip to content

FletStaticFiles 继承自: StaticFiles

用于提供 Flet 应用的静态资源文件。

参数: assets_dir:应用静态资源目录的路径。相对路径会相对于当前工作目录解析。 app_name:PWA 应用名称。 app_short_name:PWA 应用短名称。 app_description:PWA 应用描述。 web_renderer:Web 渲染器类型。 route_url_strategy:路由 URL 策略。 no_cdn:是否不从 CDN 加载 CanvasKit、Pyodide 与字体。 websocket_endpoint_path:Flet 应用 WebSocket 处理器的路径。不带前导 / 的路径会相对于应用挂载路径解析,默认值为 ws。

方法 ​

名称类型默认值说明
lookup_pathtuple[str, Optional[os.stat_result]]—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. Args: path: Requested path, relative to the mounted static root (e.g. "about", "sample.json"). Returns: A (full_path, stat_result) tuple. When stat_result is None, Starlette responds with 404.

关注我,学习大模型、大数据、Python等热门技术。