Utilisation de @rt pour la route Media
Build and Push Docker Image / build-and-push (push) Successful in 37s

This commit is contained in:
xavier committed 2026-08-26 20:02:22 +02:00
1 parent 937e877ee2
commit 7a0f580fa8
1 file changed
+4 -3
+4 -3
View File
@@ -51,15 +51,16 @@ app, rt = fast_app(
app.mount("/Logo", StaticFiles(directory="Logo"), name="Logo") app.mount("/Logo", StaticFiles(directory="Logo"), name="Logo")
# --- LECTURE EN RAM (Syntaxe Native FastHTML) --- # --- LECTURE EN RAM (Syntaxe Native FastHTML) ---
@rt('/Media/{fname}') @rt('/Media/{fname:path}')
def get(fname: str): def get(fname: str):
chemin = os.path.join(dossier_media, fname) chemin = os.path.join(dossier_media, fname)
if os.path.exists(chemin):
try: try:
with open(chemin, "rb") as f: with open(chemin, "rb") as f:
return Response(content=f.read(), media_type="image/png") return Response(content=f.read(), media_type="image/png")
except Exception as e: except Exception as e:
# Si ça plante ici, ça renverra une erreur 500 visible, PAS un 404 silencieux ! return HTMLResponse(f"Erreur lecture RAM : {e}", status_code=500)
return HTMLResponse(f"<h1 style='color:red;'>Erreur RAM: {e}</h1>", status_code=500) return HTMLResponse("Fichier introuvable", status_code=404)
# --- ROUTES D'AUTHENTIFICATION --- # --- ROUTES D'AUTHENTIFICATION ---
@rt('/login') @rt('/login')