Recall & Review
beginner
What is environment-based configuration in Flask?
It means setting up your Flask app to use different settings depending on where it runs, like development, testing, or production. This helps keep things organized and safe.
Click to reveal answer
beginner
How do you tell Flask to use a specific configuration file?
You use app.config.from_object() or app.config.from_pyfile() to load settings from a Python file or object that matches your environment.
Click to reveal answer
beginner
Why should you avoid hardcoding sensitive info like passwords in your Flask config?
Because hardcoding secrets can expose them if your code is shared. Instead, use environment variables or separate config files that are not shared publicly.
Click to reveal answer
intermediate
What is the purpose of the FLASK_ENV environment variable?
It tells Flask which environment it is running in, like 'development' or 'production', so Flask can adjust settings like debug mode automatically.
Click to reveal answer
intermediate
How can you switch configurations without changing your code in Flask?
By setting environment variables outside your code, like FLASK_ENV or custom variables, and loading config based on those variables.
Click to reveal answer
Which Flask method loads configuration from a Python file?
✗ Incorrect
app.config.from_pyfile() loads configuration from a Python file.
What does setting FLASK_ENV=production do in Flask?
✗ Incorrect
Setting FLASK_ENV=production disables debug mode and optimizes Flask for production use.
Why use environment variables for configuration?
✗ Incorrect
Environment variables keep sensitive info out of code and allow easy changes without code edits.
Which is NOT a common Flask environment?
✗ Incorrect
'debugging' is not a standard Flask environment; common ones are development, testing, and production.
How can you load different configs based on environment in Flask?
✗ Incorrect
You can check environment variables in your code and load different configs accordingly.
Explain how environment-based configuration helps in Flask app development and deployment.
Think about why you wouldn't want the same settings everywhere.
You got /3 concepts.
Describe how to set up and switch between multiple configuration files in a Flask app.
Consider how your app knows which config to use.
You got /3 concepts.