Complete the code to load environment variables from a .env file using Flask.
from flask import Flask from dotenv import [1] app = Flask(__name__) [1]()
The load_dotenv() function loads environment variables from a .env file into the environment.
Complete the code to access the environment variable named 'SECRET_KEY' in Flask.
import os secret_key = os.environ.get([1])
Environment variables are accessed by their exact names as strings. Here, the variable is 'SECRET_KEY'.
Fix the error in the code to set a default value for an environment variable 'DATABASE_URL' if it is not set.
import os database_url = os.environ.get('DATABASE_URL', [1])
Providing a default database URL string like 'sqlite:///default.db' ensures the app has a fallback connection string.
Fill both blanks to create a Flask config from environment variables with a fallback default.
app.config['DEBUG'] = os.environ.get([1], [2]) == 'True'
The environment variable 'FLASK_DEBUG' is checked, and if missing, defaults to 'False'. The comparison to string 'True' sets the boolean.
Fill all three blanks to create a dictionary of environment variables filtered by a prefix.
filtered_env = {k: v for k, v in os.environ.items() if k.startswith([1]) and v != [2] and len(v) > [3]This code filters environment variables starting with 'ENV_', excludes empty strings, and only includes values longer than 0 characters.