Complete the code to set the secret key for a Flask app.
app = Flask(__name__) app.secret_key = '[1]'
The secret key must be a string used by Flask to secure sessions and cookies.
Complete the code to import the module needed to generate a random secret key.
import [1] app.secret_key = os.urandom(24)
The os module provides the urandom function to generate random bytes for the secret key.
Fix the error in setting the secret key to a byte string.
app.secret_key = [1]'supersecret'
The prefix b before the string literal indicates a byte string in Python.
Fill both blanks to set the secret key from an environment variable.
import [1] app.secret_key = os.[2]('SECRET_KEY')
Use the os module and its getenv function to read environment variables.
Fill all three blanks to create a Flask app with a secret key from environment or fallback.
import [1] app = Flask(__name__) app.secret_key = os.[2]('SECRET_KEY', [3])
This code imports os, creates the app, and sets the secret key from the environment variable SECRET_KEY or uses a default string if not set.