feat: update frontend path to '/badge' and adjust related documentation

This commit is contained in:
EmanueleAlfano
2026-02-04 13:12:15 +01:00
parent 77bea025fa
commit 458b074f45
10 changed files with 471 additions and 37 deletions

View File

@@ -85,20 +85,20 @@ def create_app(data: dict, serve_frontend: bool = True) -> FastAPI:
if serve_frontend and STATIC_DIR.exists():
print(f"🌐 Frontend statico servito da: {STATIC_DIR}")
# Serve index.html per la root e tutte le route SPA
@app.get("/")
async def serve_index():
# Serve index.html su /badge e sue sub-route
@app.get("/badge")
async def serve_badge_index():
return FileResponse(STATIC_DIR / "index.html")
@app.get("/debug")
async def serve_debug():
@app.get("/badge/debug")
async def serve_badge_debug():
return FileResponse(STATIC_DIR / "index.html")
# Monta i file statici (JS, CSS, assets) - DEVE essere dopo le route
app.mount("/assets", StaticFiles(directory=STATIC_DIR / "assets"), name="assets")
# Monta i file statici (JS, CSS, assets) sotto /badge
app.mount("/badge/assets", StaticFiles(directory=STATIC_DIR / "assets"), name="assets")
# Fallback per altri file statici nella root (favicon, ecc.)
@app.get("/{filename:path}")
# Fallback per altri file statici sotto /badge (favicon, ecc.)
@app.get("/badge/{filename:path}")
async def serve_static(filename: str):
file_path = STATIC_DIR / filename
if file_path.exists() and file_path.is_file():
@@ -179,7 +179,7 @@ def main():
print(f"📍 Server in ascolto su http://{args.host}:{args.port}")
print(f"📚 Documentazione API su http://{args.host}:{args.port}/docs")
if not args.api_only and STATIC_DIR.exists():
print(f"🌐 Frontend disponibile su http://{args.host}:{args.port}/")
print(f"🌐 Frontend disponibile su http://{args.host}:{args.port}/badge")
print("=" * 50)
# Crea e avvia l'app