Spaces:
Sleeping
Sleeping
Update Summarization/main.py
Browse files- Summarization/main.py +12 -4
Summarization/main.py
CHANGED
@@ -43,9 +43,17 @@ async def caption(file: UploadFile = File(...)):
|
|
43 |
except Exception as e:
|
44 |
return JSONResponse({"error": str(e)}, status_code=500)
|
45 |
|
46 |
-
@app.get("/files/{filename}")
|
47 |
async def serve_file(filename: str):
|
48 |
filepath = os.path.join(tempfile.gettempdir(), filename)
|
49 |
-
|
50 |
-
|
51 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
43 |
except Exception as e:
|
44 |
return JSONResponse({"error": str(e)}, status_code=500)
|
45 |
|
46 |
+
@app.get("/files/{filename}")
|
47 |
async def serve_file(filename: str):
|
48 |
filepath = os.path.join(tempfile.gettempdir(), filename)
|
49 |
+
|
50 |
+
if not os.path.exists(filepath):
|
51 |
+
return JSONResponse({"error": "File not found"}, status_code=404)
|
52 |
+
|
53 |
+
# Determine media type for proper browser handling
|
54 |
+
media_type, _ = mimetypes.guess_type(filename)
|
55 |
+
return FileResponse(
|
56 |
+
filepath,
|
57 |
+
media_type=media_type or "application/octet-stream",
|
58 |
+
filename=filename
|
59 |
+
)
|