I'm trying to download a PDF file using flask but I don't want the file to download as an attachment. I simply want it to appear in the user's browser as a separate webpage. I've tried passing the as_attachment=False
option to the send_from_directory
method but no luck.
Here is my function so far:
@app.route('/download_to_browser')
def download_to_browser(filename):
return send_from_directory(directory=some_directory,
filename=filename,
as_attachment=False)
The function works in the sense that the file is downloading to my computer but I'd much rather just display it in the browser (and let the user download the file if they want to).
I read here I need to change thecontent-disposition
parameter but I'm not sure how that can be done efficiently (perhaps using a custom response?). Any help?
Note: I'm not using Flask-Uploads at the moment but I probably will down the line.