InterviewHubPRO
Section Overview
Q49

Question 49 of 65

Part 4: Web Frameworks, APIs & FastAPI (41 - 55)

75%
Python & FastAPI•Part 4: Web Frameworks, APIs & FastAPI (41 - 55)

Application Factory Pattern in Flask:

In Simple Words: Enables creating multiple instances of a Flask app with different configurations (e.g. testing vs production) by defining a create_app() factory function.

python
from flask import Flask

def create_app(config_name="default"):
    app = Flask(__name__)
    if config_name == "testing":
        app.config["TESTING"] = True
    # Register blueprints & extensions here
    return app