Managing the Configurations: Set Up ENV Variable

Learn how to set up ENV variables within the application's configuration.

We'll cover the following

Issues in configuration

We saw earlier how to set the FLASK_APP, and how FLASK_ENV can be used to set application configuration variables from environment variables. Other uses of the configuration variables could include specifying URLs for related services, specifying secret keys used for security, details needed to establish a database connection and configuration details for logging. In general, there can be a lot of configuration options to juggle. The settings for these values might be different for different uses. For example, you might first develop your API using SQLite, and make sure it works on a local copy of Postgres, then deploy to the cloud, where the Postgres connection string must be loaded from an environment variable. If you find yourself repeatedly changing a configuration file, or values in the Python code, and re-running, then you are doing it wrong.

Uses of the configuration variables could include:

  • Specifying URLs for related services
  • Specifying secret keys used for security
  • Details needed to establish a database connection
  • Configuration details for logging

Get hands-on with 1200+ tech skills courses.