feat: add Content-Disposition header for file downloads in download_scale_results

- Enhanced the download_scale_results function to include a Content-Disposition header, specifying the filename for the "psychoscales.db" file download. This improves the user experience by prompting the correct file name during downloads.
This commit is contained in:
Miu Li 2025-06-17 16:10:19 +08:00
parent 3eb477161e
commit 1bd19235e0

1
app.py
View File

@ -273,6 +273,7 @@ async def download_scale_results(scale_id: str, db: Session = Depends(get_db)):
return FileResponse( return FileResponse(
"psychoscales.db", "psychoscales.db",
headers={ headers={
"Content-Disposition": f'attachment; filename="psychoscales.db"',
"Cache-Control": "no-store, no-cache, must-revalidate, max-age=0", "Cache-Control": "no-store, no-cache, must-revalidate, max-age=0",
"Pragma": "no-cache", "Pragma": "no-cache",
"Expires": "0" "Expires": "0"