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")
|
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)
|
||||||
try:
|
if os.path.exists(chemin):
|
||||||
with open(chemin, "rb") as f:
|
try:
|
||||||
return Response(content=f.read(), media_type="image/png")
|
with open(chemin, "rb") as f:
|
||||||
except Exception as e:
|
return Response(content=f.read(), media_type="image/png")
|
||||||
# Si ça plante ici, ça renverra une erreur 500 visible, PAS un 404 silencieux !
|
except Exception as e:
|
||||||
return HTMLResponse(f"<h1 style='color:red;'>Erreur RAM: {e}</h1>", status_code=500)
|
return HTMLResponse(f"Erreur lecture RAM : {e}", status_code=500)
|
||||||
|
return HTMLResponse("Fichier introuvable", status_code=404)
|
||||||
|
|
||||||
# --- ROUTES D'AUTHENTIFICATION ---
|
# --- ROUTES D'AUTHENTIFICATION ---
|
||||||
@rt('/login')
|
@rt('/login')
|
||||||
|
|||||||
Reference in new issue
Block a user