ikraamkb commited on
Commit
fcf2242
·
verified ·
1 Parent(s): 1b7896f

Update Summarization/main.py

Browse files
Files changed (1) hide show
  1. 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}") #for download resume as pdf
47
  async def serve_file(filename: str):
48
  filepath = os.path.join(tempfile.gettempdir(), filename)
49
- if os.path.exists(filepath):
50
- return FileResponse(filepath)
51
- return JSONResponse({"error": "File not found"}, status_code=404)
 
 
 
 
 
 
 
 
 
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
+ )