Bird
0
0

Given this factory function, what will print(app.config['DEBUG']) output?

medium📝 component behavior Q13 of 15
Flask - Ecosystem and Patterns
Given this factory function, what will print(app.config['DEBUG']) output?
def create_app():
    app = Flask(__name__)
    app.config.from_mapping(DEBUG=True)
    return app

app = create_app()
print(app.config['DEBUG'])
ANone
BTrue
CFalse
DKeyError
Step-by-Step Solution
Solution:
  1. Step 1: Analyze config setting

    The factory sets DEBUG=True using app.config.from_mapping().
  2. Step 2: Check printed value

    After creating the app, printing app.config['DEBUG'] outputs the value set, which is True.
  3. Final Answer:

    True -> Option B
  4. Quick Check:

    Config DEBUG set True = True [OK]
Quick Trick: Config values set in factory are accessible after app creation [OK]
Common Mistakes:
MISTAKES
  • Assuming default DEBUG is False
  • Expecting KeyError if not set globally
  • Confusing config keys with environment variables

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Flask Quizzes