from flask import Flask from app.config import Config, SYDNEY_TZ from app.db import init_db, close_db def create_app(): app = Flask(__name__) app.config.from_object(Config) # Database lifecycle init_db(app) app.teardown_appcontext(close_db) # Jinja2 filter: convert UTC to Sydney time @app.template_filter('sydney') def sydney_time_filter(dt, fmt='%d %b %Y, %H:%M'): from datetime import timezone if dt is None: return '' if dt.tzinfo is None: dt = dt.replace(tzinfo=timezone.utc) return dt.astimezone(SYDNEY_TZ).strftime(fmt) # Make milestone labels available to all templates from app.utils import MILESTONE_LABELS app.jinja_env.globals['MILESTONE_LABELS'] = MILESTONE_LABELS # Register blueprints from app.routes.auth import bp as auth_bp from app.routes.dashboard import bp as dashboard_bp from app.routes.checkin import bp as checkin_bp from app.routes.profile import bp as profile_bp from app.routes.leaderboard import bp as leaderboard_bp from app.routes.api import bp as api_bp app.register_blueprint(auth_bp) app.register_blueprint(dashboard_bp) app.register_blueprint(checkin_bp) app.register_blueprint(profile_bp) app.register_blueprint(leaderboard_bp) app.register_blueprint(api_bp) return app