05/22 Enhance codes and fix bugs 2
This commit is contained in:
+7
-2
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user