Spaces:
Running
on
T4
Running
on
T4
Commit
·
9f08861
1
Parent(s):
ddde5c1
removed auth for downloading
Browse files
app.py
CHANGED
|
@@ -1043,9 +1043,17 @@ async def submit(
|
|
| 1043 |
raise HTTPException(status_code=status.HTTP_500_INTERNAL_SERVER_ERROR, detail=str(e))
|
| 1044 |
|
| 1045 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1046 |
@fastapi_app.get("/download/{filename}")
|
| 1047 |
-
def download(filename: str
|
| 1048 |
-
safe_name = os.path.basename(filename)
|
| 1049 |
for p in [os.path.join(OUTPUT_DIR, safe_name), os.path.join(INPUT_DIR, safe_name)]:
|
| 1050 |
if os.path.isfile(p):
|
| 1051 |
return FileResponse(p, filename=safe_name)
|
|
|
|
| 1043 |
raise HTTPException(status_code=status.HTTP_500_INTERNAL_SERVER_ERROR, detail=str(e))
|
| 1044 |
|
| 1045 |
|
| 1046 |
+
# @fastapi_app.get("/download/{filename}")
|
| 1047 |
+
# def download(filename: str, _: bool = Depends(_verify_bearer_token)):
|
| 1048 |
+
# safe_name = os.path.basename(filename)
|
| 1049 |
+
# for p in [os.path.join(OUTPUT_DIR, safe_name), os.path.join(INPUT_DIR, safe_name)]:
|
| 1050 |
+
# if os.path.isfile(p):
|
| 1051 |
+
# return FileResponse(p, filename=safe_name)
|
| 1052 |
+
# raise HTTPException(status_code=404, detail="File not found")
|
| 1053 |
+
|
| 1054 |
@fastapi_app.get("/download/{filename}")
|
| 1055 |
+
def download(filename: str):
|
| 1056 |
+
safe_name = os.path.basename(filename) # prevent path traversal
|
| 1057 |
for p in [os.path.join(OUTPUT_DIR, safe_name), os.path.join(INPUT_DIR, safe_name)]:
|
| 1058 |
if os.path.isfile(p):
|
| 1059 |
return FileResponse(p, filename=safe_name)
|