Document the 2026-11-05 UI/UX upgrade and keep roster/live gates aligned with face-check and presence. Co-authored-by: Cursor <cursoragent@cursor.com>
46 lines
1.2 KiB
Python
46 lines
1.2 KiB
Python
#!/usr/bin/env python3
|
||
"""统一后端启动:uvicorn app.main:app"""
|
||
from __future__ import annotations
|
||
|
||
import os
|
||
import sys
|
||
from pathlib import Path
|
||
|
||
ROOT = Path(__file__).resolve().parent
|
||
SERVICES = ROOT / "services"
|
||
sys.path.insert(0, str(ROOT))
|
||
sys.path.insert(0, str(SERVICES))
|
||
|
||
# Must load before any nomadro_pb / social_svc import (PB admin empty → chat 500 offline)
|
||
try:
|
||
from dotenv import load_dotenv
|
||
|
||
load_dotenv(ROOT / ".env")
|
||
load_dotenv(ROOT / ".env.local", override=True)
|
||
except Exception:
|
||
pass
|
||
|
||
_LOCAL_ENV = """# 本地开发自动生成 — 勿提交
|
||
DEBUG=true
|
||
WX_ALLOW_DEVTOOLS_LOGIN=true
|
||
"""
|
||
|
||
|
||
def _ensure_local_env() -> None:
|
||
"""缺 .env 时自动写入本地调试开关,避免手动配。"""
|
||
if os.getenv("NOMADRO_ENV", "").lower() in {"prod", "production"}:
|
||
return
|
||
env_path = ROOT / ".env"
|
||
if env_path.exists():
|
||
return
|
||
env_path.write_text(_LOCAL_ENV, encoding="utf-8")
|
||
|
||
|
||
if __name__ == "__main__":
|
||
import uvicorn
|
||
|
||
_ensure_local_env()
|
||
host = os.getenv("HOST", "127.0.0.1")
|
||
port = int(os.getenv("PORT", "8080"))
|
||
uvicorn.run("app.main:app", host=host, port=port, reload=os.getenv("RELOAD") == "1")
|