Bird
0
0

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

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

app = create_app()
ANone
BTrue
CFalse
DKeyError
Step-by-Step Solution
Solution:
  1. Step 1: Analyze the factory function

    The function creates a Flask app and sets 'TESTING' config to True before returning the app.
  2. Step 2: Understand the print statement

    After calling create_app(), app.config['TESTING'] is True, so printing it outputs True.
  3. Final Answer:

    True -> Option B
  4. Quick Check:

    Config value for TESTING = True [OK]
Quick Trick: Config set in factory is accessible after creation [OK]
Common Mistakes:
MISTAKES
  • Expecting default False
  • Assuming config key missing causes error
  • Thinking config is None by default

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Flask Quizzes