When the user enteres
http://ift.tt/1aSPjZk the code below generates a data.csv file and serves it to the browser. It was perfectly on my localhost.
However, I have deployed it behind an API proxy, so that the user makes a call to
http://ift.tt/1JcKTeT which is internally transformed into
As a result, instead of serving data.csv to the browser as on localhost, it shows on the browser all the data. The view source-code feature shows exactly what data.csv should contain, but it is not being served as attachement. Any ideas?
from flask import make_response @app.route('/', methods = ['GET']) def get_file(): alldata =  while len(new_data) > 0: new_data = api.timeline(max_id=oldest) alldata.extend(new_data) oldest = alldata[-1].id - 1 outdata = "" for data in alldata: outdata += ",".join(data) + "\n" response = make_response(outdata) response.headers["Content-Disposition"] = "attachment; filename=data.csv" return response if __name__ == '__main__': app.run(host = app.config['HOST'], port = app.config['PORT'])