Categories
Python Answers

How to get the root path of a Python Flask application?

Spread the love

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.

By John Au-Yeung

Web developer specializing in React, Vue, and front end development.

Leave a Reply

Your email address will not be published. Required fields are marked *