31 lines
No EOL
684 B
Python
31 lines
No EOL
684 B
Python
from flask import Flask
|
|
from flask_sqlalchemy import SQLAlchemy
|
|
from config import config
|
|
|
|
db = SQLAlchemy()
|
|
|
|
|
|
def create_app(config_name="default"):
|
|
"""Application factory function.
|
|
|
|
Args:
|
|
config_name: Configuration name (development, testing, production).
|
|
|
|
Returns:
|
|
Configured Flask application instance.
|
|
"""
|
|
app = Flask(__name__)
|
|
app.config.from_object(config[config_name])
|
|
|
|
# Initialize extensions
|
|
db.init_app(app)
|
|
|
|
# Register blueprints
|
|
from app.routes import main as main_blueprint
|
|
app.register_blueprint(main_blueprint)
|
|
|
|
# Create database tables
|
|
with app.app_context():
|
|
db.create_all()
|
|
|
|
return app |