0
0
Flaskframework~5 mins

Configuration management in Flask - Cheat Sheet & Quick Revision

Choose your learning style9 modes available
Recall & Review
beginner
What is configuration management in Flask?
It is the process of setting up and managing settings that control how a Flask app behaves, like database info, debug mode, or secret keys.
Click to reveal answer
beginner
How do you load configuration from a Python file in Flask?
Use app.config.from_pyfile('config.py') to load settings from a Python file named config.py.
Click to reveal answer
beginner
What is the purpose of SECRET_KEY in Flask configuration?
It is used to keep client sessions secure and protect against attacks like CSRF by signing cookies and forms.
Click to reveal answer
intermediate
How can environment variables be used in Flask configuration?
You can read environment variables in your config file or code to set values dynamically, helping keep secrets out of code.
Click to reveal answer
intermediate
What is the difference between app.config.from_object() and app.config.from_pyfile()?
from_object() loads config from a Python object or class, while from_pyfile() loads from a Python file on disk.
Click to reveal answer
Which Flask method loads configuration from a Python file?
Aapp.config.from_pyfile()
Bapp.load_config()
Capp.config.load_file()
Dapp.set_config()
What is the role of SECRET_KEY in Flask?
ATo secure sessions and sign cookies
BTo set the app's debug mode
CTo configure the database URL
DTo define the app's port number
How can you keep sensitive info like passwords out of your Flask code?
AHardcode them in the app.py
BStore them in static files
CPrint them in logs
DUse environment variables
Which method loads config from a Python class or object?
Aapp.config.load_class()
Bapp.config.from_pyfile()
Capp.config.from_object()
Dapp.config.from_envvar()
What is a good practice for managing different configs for development and production?
AUse the same config for all environments
BUse separate config files or classes for each environment
CHardcode production settings in development
DChange config manually in the code each time
Explain how Flask configuration management helps keep your app flexible and secure.
Think about how settings control app behavior and protect sensitive info.
You got /5 concepts.
    Describe the steps to set up configuration in a Flask app using a Python file and environment variables.
    Consider how to combine files and environment for flexible config.
    You got /5 concepts.