How to change downloading name in flask?

前端 未结 4 2105
名媛妹妹
名媛妹妹 2021-02-18 17:06

I have a small project which has to response some files. I know that using nginx will be better decision but that files a really small.

Part of my program:

4条回答
  •  情深已故
    2021-02-18 17:19

    I had this problem before, I tried many of solutions mentioned here and finally I could fix the problem by writing the correct mimetype of the file

    here my example:

    @app.route('/download_report')
    def download_summary():
        return send_file('Report.csv', mimetype='application/x-csv', attachment_filename='summary_report.csv', as_attachment=True)
    

提交回复
热议问题