From d99d7f7c1215ac71b4c3c15fca72ce4a1eb30640 Mon Sep 17 00:00:00 2001 From: mxr612 Date: Mon, 16 Jun 2025 09:32:23 +0800 Subject: [PATCH] fix: correct public file path handling in get_public_file function - Moved the public_path assignment to ensure it is set before checking for the file's existence. - This change resolves potential issues when accessing files in the public directory. --- app.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app.py b/app.py index aa882bf..1e74f44 100644 --- a/app.py +++ b/app.py @@ -197,12 +197,12 @@ def generate_sitemap(): # Mount all files from public directory to root @app.get("/{filename}") async def get_public_file(filename: str): - public_path = os.path.join("public", filename) if filename == "sitemap.xml": return Response( content=generate_sitemap(), media_type="application/xml" ) + public_path = os.path.join("public", filename) if os.path.isfile(public_path): return FileResponse(public_path) raise HTTPException(status_code=404, detail="File not found")