这是一种不使用Javascript下载CSV文件的方法:
#!/usr/bin/pythonfrom flask import Flask, Responseapp = Flask(__name__)@app.route("/")def hello(): return ''' <html><body> Hello. <a href="/getPlotCSV">Click me.</a> </body></html> '''@app.route("/getPlotCSV")def getPlotCSV(): # with open("outputs/Adjacency.csv") as fp: # csv = fp.read() csv = '1,2,3n4,5,6n' return Response( csv, mimetype="text/csv", headers={"Content-disposition": "attachment; filename=myplot.csv"})app.run(debug=True)


