Managing the configuration: YAML File
Explore how to manage Flask API configurations effectively by using YAML files to organize environment-specific settings. Understand how to leverage environment variables for sensitive data and achieve consistency between development and production environments to avoid deployment issues.
We'll cover the following...
We'll cover the following...
Setting up a YAML file
Here is how we’ll set up the config.yaml file to group configuration options together:
When subsequent lines in a YAML file are indented like this, it means the values are nested. This will be read as the following dictionary of dictionaries in Python:
{ 'dev_lite': { 'DB':'sqlite:///books.db' },
'dev_postgres': { 'DB':'postgres://localhost:5432/books' } }
The YAML file will be used to describe two different environments. In the dev_lite environment, which is the development environment using SQLite, the database connection string, DB ...