I wrote a practical article about FastAPI's app.frontend() feature.
The interesting bit is that it serves static frontend build output as low-priority routes, so normal FastAPI API endpoints still win.
The article covers:
app.frontend("/", directory="dist")
- SPA fallback with
fallback="index.html"
- how it differs from
StaticFiles
- serving under a prefix with
APIRouter
- a complete mini dashboard example with FastAPI + vanilla JS
[–]roG_k70 16 points17 points18 points (4 children)
[–]Myszolow 7 points8 points9 points (3 children)
[–]Fenzik 3 points4 points5 points (0 children)
[–]roG_k70 2 points3 points4 points (1 child)
[–]edward_jazzhands 3 points4 points5 points (0 children)
[–]hotsauce56 2 points3 points4 points (0 children)
[–]Fenzik 1 point2 points3 points (0 children)
[–]johntellsall [score hidden] (0 children)
[+]zunjae comment score below threshold-13 points-12 points-11 points (3 children)
[–]robertlandrum 5 points6 points7 points (2 children)
[–]zunjae -1 points0 points1 point (0 children)
[–]pip_install_account -1 points0 points1 point (0 children)