Issue
I'm writing a web portal in Flask for downloading files from a server. I'm currently trying to use Flask's send_file() command. When I build the site and click' download', the Python download function Python server-side is running and no error messages are returned, I'm never prompted to save a file. I'm working in Windows 10 under Python 3.
I've attempted to use send_from_directory(), but it acts the same way - no errors are thrown, but I am never prompted to download a file.
@app.route('/download_file', methods = ['POST'])
def background_process_test():
data = request.data.decode("utf-8")[1:-1]
path = "C:/Users/ehill/OneDrive - LeTourneau University/Code/Python/call-portal/call-portal/"
print (path + data)
return send_file(path + data, as_attachment=True, attachment_filename=data)
From the console, I'm receiving as expected:
C:/Users/ehill/OneDrive - LeTourneau University/Code/Python/call-portal/call-portal/Call03.wav
127.0.0.1 - - [04/Jan/2019 15:58:52] "POST /download_file HTTP/1.1" 200 -
But this is all that happens. The path is valid and works when dropped into Windows Explorer. As a note, my browser window doesn't open a new tab or refresh.
Thank you for your feedback.
Solution
Turn on dev tools in Chrome ( ctr-shift-I ). For me this problem was caused by a "mixed content" error that was only visible in the dev tools of the browser. And the source of that error was that while trouble shooting a different problem I had changed the azure web service TLS/SSL settings to be "HTTPS only = ON". After flipping the setting back my calls to send_file()
all started behaving normally.
Answered By - L_Daniels
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.