Spaces:
Running
Running
Guilherme Silberfarb Costa commited on
Commit ·
5bccf4a
1
Parent(s): cea3254
Serve full frontend dist in FastAPI for public assets
Browse files- backend/app/main.py +3 -6
backend/app/main.py
CHANGED
|
@@ -4,7 +4,6 @@ from pathlib import Path
|
|
| 4 |
|
| 5 |
from fastapi import FastAPI
|
| 6 |
from fastapi.middleware.cors import CORSMiddleware
|
| 7 |
-
from fastapi.responses import FileResponse
|
| 8 |
from fastapi.staticfiles import StaticFiles
|
| 9 |
|
| 10 |
from app.api import elaboracao, health, session, visualizacao
|
|
@@ -36,11 +35,9 @@ def _mount_frontend_if_exists() -> None:
|
|
| 36 |
if not index_file.exists():
|
| 37 |
return
|
| 38 |
|
| 39 |
-
|
| 40 |
-
|
| 41 |
-
|
| 42 |
-
def serve_spa(full_path: str) -> FileResponse:
|
| 43 |
-
return FileResponse(index_file)
|
| 44 |
|
| 45 |
|
| 46 |
_mount_frontend_if_exists()
|
|
|
|
| 4 |
|
| 5 |
from fastapi import FastAPI
|
| 6 |
from fastapi.middleware.cors import CORSMiddleware
|
|
|
|
| 7 |
from fastapi.staticfiles import StaticFiles
|
| 8 |
|
| 9 |
from app.api import elaboracao, health, session, visualizacao
|
|
|
|
| 35 |
if not index_file.exists():
|
| 36 |
return
|
| 37 |
|
| 38 |
+
# Serve the entire Vite build output so root-level files from public/
|
| 39 |
+
# (e.g. /logo_mesa.png) and hashed /assets files are both available.
|
| 40 |
+
app.mount("/", StaticFiles(directory=frontend_dist, html=True), name="frontend")
|
|
|
|
|
|
|
| 41 |
|
| 42 |
|
| 43 |
_mount_frontend_if_exists()
|