Complete the code to load configuration from a Python file in Flask.
app = Flask(__name__)
app.config.from_pyfile([1])Flask's from_pyfile method expects the filename as a string, so you must pass the filename in quotes.
Complete the code to set a configuration value directly in Flask.
app = Flask(__name__) app.config[[1]] = 'development'
Configuration keys must be strings, so use quotes around ENV.
Fix the error in loading configuration from an object in Flask.
class Config: DEBUG = True app = Flask(__name__) app.config.from_object([1])
The from_object method expects the class or its import path as a string, but passing the class itself (without parentheses) is correct.
Fill both blanks to create a config dictionary with only keys starting with 'MYAPP_'.
filtered_config = {k: v for k, v in app.config.items() if k.[1]('MYAPP_') and v [2] None}Use startswith to check key prefix and is not to exclude None values.
Fill all three blanks to load config from environment variable and fallback to default.
import os config_path = os.getenv([1], [2]) app.config.from_pyfile([3])
Use os.getenv with the environment variable name and default file. Then load config from the resolved path.