05/22 Enhance codes and fix bugs 2

This commit is contained in:
2026-05-22 10:46:43 -04:00
parent 3231c8eb56
commit f5dc6660c5
7 changed files with 80 additions and 29 deletions
+7 -2
View File
@@ -110,7 +110,7 @@ def create_app(config_name: str = 'development') -> Flask:
@login_manager.user_loader
def load_user(user_id):
return User.query.get(int(user_id))
return db.session.get(User, int(user_id))
# Blueprints
from .routes.auth import auth_bp
@@ -226,7 +226,12 @@ def create_app(config_name: str = 'development') -> Flask:
id='token_blacklist_cleanup',
replace_existing=True,
)
scheduler.start()
# In Flask debug mode the Werkzeug reloader spawns two processes.
# WERKZEUG_RUN_MAIN == 'true' only in the child (the actual server),
# so we skip the scheduler in the parent reloader to avoid duplicate jobs.
import os
if not app.debug or os.environ.get('WERKZEUG_RUN_MAIN') == 'true':
scheduler.start()
# ── Production safety checks ───────────────────────────────────────────────
# Warn loudly at startup when running in production with settings that are