【发布时间】:2020-11-19 14:11:10
【问题描述】:
我编写了一个 API,用于根据用户在 Web 应用程序中填写表单的内容向用户返回 CSV。运行下面的代码时,我可以在控制台中看到响应,并确定我的 API 正确返回了内容,但我似乎无法让文件自动开始下载。任何建议将不胜感激!
csv = final_df.to_csv()
response = make_response(csv)
response.headers['Content-Disposition'] = "attachment; filename=export.csv"
response.headers['Content-type'] = "application/force-download"
return response
【问题讨论】:
-
也许this 会帮助你解决你的问题
标签: python flask http-headers downloadfile