Answer the question
In order to leave comments, you need to log in
Why is Flask not downloading a file?
I'm trying to download a file from my application, but for some reason it doesn't work.
Here is my method
@admin.route('/download_doc', methods=['GET', 'POST'])
def download_doc():
doc_id = request.json['id']
doc = Doc.query.filter(Doc.id==doc_id).first()
filename = doc.filename
return send_from_directory(app.config['UPLOAD_FOLDER'], filename, as_attachment=True)
UPLOAD_FOLDER = 'static\doc'
app.config['UPLOAD_FOLDER'] = UPLOAD_FOLDER
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question