| 1234567891011121314151617181920212223242526272829303132333435 |
- """Application factory."""
- from flask import Flask
- from app.config.setting import config
- def register_blueprints(app):
- """Register all application blueprints."""
- from app.api.v1 import create_blueprint_v1
- from app.routes.health import bp as health_bp
- # API v1 under /v1
- app.register_blueprint(create_blueprint_v1(), url_prefix="/v1")
- # Health endpoint at /health
- app.register_blueprint(health_bp)
- def create_app(env: str = "default"):
- """Create and configure the Flask application."""
- app = Flask(__name__)
- app.config.from_object(config[env])
- # optional: initialize logging and other extensions here
- try:
- from app.utils.logger import setup_logging
- setup_logging(app)
- except Exception:
- # keep app creation robust even if logging setup fails
- pass
- register_blueprints(app)
- return app
|