Bird
0
0

Which of the following is the correct way to set a secret key in a Flask app for session security?

easy📝 Syntax Q12 of 15
Flask - Security Best Practices
Which of the following is the correct way to set a secret key in a Flask app for session security?
Aapp.set_secret('mysecret')
Bapp.secret_key = 'mysecret'
Capp.SECRET = 'mysecret'
Dapp.session_key = 'mysecret'
Step-by-Step Solution
Solution:
  1. Step 1: Recall Flask's secret key attribute

    Flask uses app.secret_key to set the secret key for signing sessions.
  2. Step 2: Verify syntax correctness

    Options A, C, and D use incorrect attribute names or methods not defined in Flask.
  3. Final Answer:

    app.secret_key = 'mysecret' -> Option B
  4. Quick Check:

    Use app.secret_key to set secret key = B [OK]
Quick Trick: Use app.secret_key to set secret key in Flask [OK]
Common Mistakes:
MISTAKES
  • Using wrong attribute names like SECRET or session_key
  • Trying to call a non-existent method set_secret
  • Confusing uppercase and lowercase attribute names

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Flask Quizzes