Main environment variables that we can use in Flask

- Andrés Cruz

En español

Main environment variables that we can use in Flask

In Flask we have multiple environment variables that we can use to perform different configurations, activate debug mode, specify the startup or main file of the application, among many other configurations that we can perform.

In this post we are going to see some of the main environment variables that we can use in Flask.

Environment variable: FLASK_APP

This has been if it is not the most important, one of the most important that we must know; with this we are indicating which is the startup file of our project in Flask; Its use is very simple:

Example of its use: (Linux and MacOS)

export FLASK_APP=run.py

With this configuration we can indicate the startup file of our application. So when we go to run the app with:

Flask run

Flask is going to take the configuration of the name that we configured before to run the app

We can also execute other types of configurations, for example, when we execute a migration with Flask Migrate, as we dealt with in the course of:

And well, there are many processes or packages that you can install in which you must specify the FLASK_APP before starting said process, since with this, we are indicating where all the dependencies and our project as such begin to be loaded.

Environment variable: FLASK_DEBUG

With this configuration we can enable or disable the debut mode in our application that serves us, for example, to show detailed information about an error that is occurring in our app and is also used by other packages, for example, Flask Google Captcha to enable the use of the captcha or disable it.

Example of its use: (Linux and MacOS)

export FLASK_DEBUG=1

Environment variable: FLASK_ENV

With this we can configure the environment of our application

Example of its use: (Windows)

set FLASK_ENV=development

You can see the full list of Flask environment variables in Environment Variables

Andrés Cruz

Develop with Laravel, Django, Flask, CodeIgniter, HTML5, CSS3, MySQL, JavaScript, Vue, Android, iOS, Flutter

Andrés Cruz In Udemy

I agree to receive announcements of interest about this Blog.

!Courses from!

10$

On Udemy

There are 4d 11:31!


Udemy

!Courses from!

4$

In Academy

View courses

!Books from!

1$

See the books
¡Become an affiliate on Gumroad!