superset icon indicating copy to clipboard operation
superset copied to clipboard

Download to .CSV and .JSON

Open jefffeng opened this issue 10 years ago • 0 comments

http://matthewmoisen.com/blog/programming/flask/how-to-download-a-csv-file-in-flask/

Sample solution:

from flask import Flask, make_response
app = Flask(__name__)

@app.route('/csv/')
def download_csv():
    csv = 'foo,bar,baz\nhai,bai,crai\n'
    response = make_response(csv)
    response.headers['Content-Disposition'] = 'attachment; filename=mycsv.csv'
    response.mimetype='text/csv'

    return response

jefffeng avatar Jul 30 '16 04:07 jefffeng