python - read a existing csv file in flask and then download it through browser -
i have existing csv file downloaded server desktop using python script. want modify code, or write new 1 download same csv file when user access link in browser. how using flask ?
import os import csv flask import flask, make_response app = flask(__name__) w_open=open(filename,'r') @app.route('/csv/') def download_csv(): csv = w_open response = make_response(csv) cd = 'attachment; filename=rosterunified.csv' response.headers['content-disposition'] = cd response.mimetype='text/csv' return response if __name__=='__main__': app.run()
Comments
Post a Comment