First Push

This commit is contained in:
喆OvO
2026-08-06 11:11:11 +08:00
commit 0fef309972
551 changed files with 15793 additions and 0 deletions
+40
View File
@@ -0,0 +1,40 @@
"""Production entry point for the Calendar Display application."""
import os
import sys
os.chdir(os.path.dirname(os.path.abspath(__file__)))
from backend.app import create_app
from backend.scheduler import start_scheduler, stop_scheduler
from backend.models import _EMITTED_PASSWORDS, get_auth_config
# Use environment variable to toggle debug, default False for production
DEBUG = os.environ.get("FLASK_DEBUG", "").lower() in ("1", "true", "yes")
db_path = os.environ.get("FLASK_DB_PATH", os.path.join(os.path.dirname(__file__), "data.db"))
app = create_app(db_path=db_path)
if __name__ == "__main__":
# In debug mode, scheduler runs only in the reloader child process
is_reloader_child = os.environ.get("WERKZEUG_RUN_MAIN") == "true"
if not DEBUG or is_reloader_child:
start_scheduler(app)
# Print temp password at startup
with app.app_context():
if not _EMITTED_PASSWORDS:
cfg = get_auth_config()
pw = cfg.get("temp_password", "")
if pw and cfg.get("must_configure_mfa"):
print(f"\n{'='*50}", file=sys.stderr)
print(f" 🔐 临时密码: {pw}", file=sys.stderr)
print(f" ⚠️ 请使用此密码登录并配置双因素认证", file=sys.stderr)
print(f"{'='*50}\n", file=sys.stderr)
try:
bind_host = os.environ.get("FLASK_BIND", "127.0.0.1")
app.run(host=bind_host, port=5001, debug=DEBUG, threaded=True)
finally:
if not DEBUG or is_reloader_child:
stop_scheduler()