Flet FastAPI . canot show assets image #2447
Unanswered
bobwatcherx
asked this question in
Q&A
Replies: 1 comment
-
import flet as ft
import flet.fastapi as flet_fastapi
from fastapi.requests import Request
from fastapi.responses import RedirectResponse
# Configs:
ASSETS_DIR = '<assets-directory-absolute-path>'
# Views:
async def home(page: ft.Page):
await page.add_async(
ft.Text('Hello App!'), ft.Image(src='../../assets/<filename>')
)
# Routes:
app = flet_fastapi.FastAPI()
@app.get('/')
async def _(request: Request):
return RedirectResponse('/views/home')
app.mount('/views/home', flet_fastapi.app(home))
# Use this link to access files in assets directory: http://localhost:8000/assets/<filename>
app.mount('/assets', flet_fastapi.FletStaticFiles(assets_dir=ASSETS_DIR)) |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Question
i follow flet docs . but not work . you can see structure folder this


Code sample
Error message
------------------------------------------------------
Beta Was this translation helpful? Give feedback.
All reactions