Download A File From A Flask-based Python Server
I'm trying to make work a code that I found at this URL: http://code.runnable.com/UiIdhKohv5JQAAB6/how-to-download-a-file-generated-on-the-fly-in-flask-for-python My goal is to be
Solution 1:
The best way to solve this issue is to use the already predefined helper function send_file()
in flask:
@app.route("/api/downloadlogfile/<path>")
def DownloadLogFile (path = None):
if path is None:
self.Error(400)
try:
return send_file(path, as_attachment=True)
except Exception as e:
self.log.exception(e)
self.Error(400)
Post a Comment for "Download A File From A Flask-based Python Server"