I am running Flask on GAE. I have an issue serving up my file. Everything seems right but nothing pops up in my browser to prompt me to save it and there are no errors in the log console:
@app.route("/submit", methods=["GET"])
def submitChecklist():
... generate json
headers = {'content-type': 'application/json', 'charset':'UTF-8'}
r = requests.post(url, data=json.dumps(jsonstring), headers=headers, stream=True)
print 'payload: ' + r.text
response = make_response(r.text)
response.headers["Content-Disposition"] = "attachment; filename=exportChecklists.xml"
return response
UPDATE
I am thinking the problem might be on the javascript side, here is what I currently have and it does not prompt download:
$.get('submit',
dat,
function(data) {
if (data.success==1)
console.log("done")
else
alert("There is an exception on server side while submitting the response!")
},'text');
I feel like the solution is here but I can't quite figure it out.
UPDATE #2
I still can't figure out how to do this so I only serve one file. While the below explanation is good in general, I can't figure out how to serve only 1 file using jQuery. Could someone please provide an example on how to do this.
Thanks for the help.