Write a create_app Function
Construct and configure the app inside a factory.
Meet the Factory
An application factory is just a function named create_app that builds a fresh Flask app, configures it, and returns it. No globals required. 🏭
The Smallest Factory
At its core, create_app creates the app inside the function body and returns it. Everything you used to do at module level moves in here.
def create_app():
app = Flask(__name__)
return appAll lessons in this course
- Problems with a Global app Object
- Write a create_app Function
- Init Extensions with init_app
- Register Blueprints in the Factory