python - How to change the name of .csv Response on Flask -


i'm using flask web service , in point have send report user. has on .csv format, i'm using code:

# ... def generate():     head 'some headers'     # loops data lists , dbs     yield 'the data'     # ... return response(generate(), mimetype = 'text/csv') 

the name of report 'someletters.csv' , user want name more descriptive, how can change name of report? looking on flask documentation , didn't find useful.

you can following in code:

filename_ = 'myfilename.csv'   # or format like. return response(generate(), mimetype="text/csv", headers={"content                  disposition":"attachment; filename=" + filename_}) 

Comments

Popular posts from this blog

php - Wordpress website dashboard page or post editor content is not showing but front end data is showing properly -

javascript - Get parameter of GET request -

javascript - Twitter Bootstrap - how to add some more margin between tooltip popup and element -