@app.route('/getPlotCSV')
def getPlotCSV():
    csv = '1,2,3\n4,5,6\n'
return Response(csv, mimetype='text/csv', headers={'Content-disposition':
    'attachment; filename=myplot.csv'})
app.run(debug=True)
Flask: Download a csv file on clicking a button