Public Access
Utilisation de @rt pour la route Media
Build and Push Docker Image / build-and-push (push) Successful in 37s
Build and Push Docker Image / build-and-push (push) Successful in 37s
This commit is contained in:
1 parent
937e877ee2
commit
7a0f580fa8
1 file changed
+8
-7
@@ -51,15 +51,16 @@ app, rt = fast_app(
|
||||
app.mount("/Logo", StaticFiles(directory="Logo"), name="Logo")
|
||||
|
||||
# --- LECTURE EN RAM (Syntaxe Native FastHTML) ---
|
||||
@rt('/Media/{fname}')
|
||||
@rt('/Media/{fname:path}')
|
||||
def get(fname: str):
|
||||
chemin = os.path.join(dossier_media, fname)
|
||||
try:
|
||||
with open(chemin, "rb") as f:
|
||||
return Response(content=f.read(), media_type="image/png")
|
||||
except Exception as e:
|
||||
# Si ça plante ici, ça renverra une erreur 500 visible, PAS un 404 silencieux !
|
||||
return HTMLResponse(f"<h1 style='color:red;'>Erreur RAM: {e}</h1>", status_code=500)
|
||||
if os.path.exists(chemin):
|
||||
try:
|
||||
with open(chemin, "rb") as f:
|
||||
return Response(content=f.read(), media_type="image/png")
|
||||
except Exception as e:
|
||||
return HTMLResponse(f"Erreur lecture RAM : {e}", status_code=500)
|
||||
return HTMLResponse("Fichier introuvable", status_code=404)
|
||||
|
||||
# --- ROUTES D'AUTHENTIFICATION ---
|
||||
@rt('/login')
|
||||
|
||||
Reference in new issue
Block a user