Sometimes, we want to get the root path of a Python Flask application.
In this article, we’ll look at how to get the root path of a Python Flask application.
How to get the root path of a Python Flask application?
To get the root path of a Python Flask application, we can use the app.instance_path
property.
For instance, we write
filename = os.path.join(app.instance_path, 'my_folder', 'my_file.txt')
to get the Flask app instance’s folder with app.instance_path
.
Conclusion
To get the root path of a Python Flask application, we can use the app.instance_path
property.