» pip install Flask
Factsheet
/ 19 February 2026; 47 days ago (19 February 2026)
/ 19 February 2026; 47 days ago (19 February 2026)
Videos
» pip install flask-app
You need to make sure that the value you pass to the directory argument is an absolute path, corrected for the current location of your application.
The best way to do this is to configure UPLOAD_FOLDER as a relative path (no leading slash), then make it absolute by prepending current_app.root_path:
@app.route('/uploads/<path:filename>', methods=['GET', 'POST'])
def download(filename):
uploads = os.path.join(current_app.root_path, app.config['UPLOAD_FOLDER'])
return send_from_directory(uploads, filename)
It is important to reiterate that UPLOAD_FOLDER must be relative for this to work, e.g. not start with a /.
A relative path could work but relies too much on the current working directory being set to the place where your Flask code lives. This may not always be the case.
To download file on flask call. File name is Examples.pdf When I am hitting 127.0.0.1:5000/download it should get download.
Example:
from flask import Flask
from flask import send_file
app = Flask(__name__)
@app.route('/download')
def downloadFile ():
#For windows you need to use drive name [ex: F:/Example.pdf]
path = "/Examples.pdf"
return send_file(path, as_attachment=True)
if __name__ == '__main__':
app.run(port=5000,debug=True)
Hi all ,
Newish to working with web and flask development . I come from doing lots of GUI development, with Tkinter and others . I have some functions that generate .csv files and then place them in a folder, usually have a file dialog that request for the user to choose . Typically I’ll save these in a config.ini file for desktop apps.
How can I do something like there in flask where I have a wtform that has the user choose where to save .csv files and on submit call my function to generate csv to that said folder , or maybe the users default download folder ?
And maybe implement some sort of progress / loading bar as well freezing the page while the function is running .
Any advice is appreciated and thanks in advance !