For my personal website, I want to have a separate page just for my résumé, which is a PDF. I\'ve tried multiple ways, but I can\'t figure out how to get flask to handle a P
You can use flask send_file or send_static_file function in 5 lines:
from flask import send_file, current_app as app
@app.route('/show/static-pdf/')
def show_static_pdf():
with open('/path/of/file.pdf', 'rb') as static_file:
return send_file(static_file, attachment_filename='file.pdf')
This snippet link is helpful
Also can use send_from_directory if you want send file from certain directory:
from flask import send_from_directory, current_app as app
@app.route('/show/PDFs/')
def send_pdf():
return send_from_directory(app.config['UPLOAD_FOLDER'], 'file.pdf')
read more about send_from_directory