b27bedbca3
- uvicorn 改用 import string 格式启动 4 workers,防止数据采集阻塞 event loop - prewarm 去掉 --force-refresh,仅依赖缓存预热避免每 5 分钟全量采集 - 积分变动时同步写入 Supabase user_metadata,避免前端回退路径失败时显示 0 积分 - /api/auth/me 积分解析增加 Supabase email 回退路径
44 lines
930 B
Python
44 lines
930 B
Python
"""
|
|
PolyWeather Web Map API
|
|
~~~~~~~~~~~~~~~~~~~~~~~
|
|
FastAPI backend that reuses existing weather data collection and analysis modules.
|
|
Serves a Leaflet-based interactive map frontend.
|
|
"""
|
|
|
|
import os
|
|
import sys
|
|
|
|
_file_dir = os.path.dirname(os.path.abspath(__file__))
|
|
_root = os.path.dirname(_file_dir)
|
|
if _root not in sys.path:
|
|
sys.path.insert(0, _root)
|
|
if _file_dir not in sys.path:
|
|
sys.path.insert(0, _file_dir)
|
|
|
|
from web.analysis_service import ( # noqa: E402
|
|
_analyze,
|
|
_build_city_detail_payload,
|
|
_build_city_summary_payload,
|
|
)
|
|
from web.app_factory import create_app # noqa: E402
|
|
|
|
app = create_app()
|
|
|
|
__all__ = [
|
|
"app",
|
|
"_analyze",
|
|
"_build_city_detail_payload",
|
|
"_build_city_summary_payload",
|
|
]
|
|
|
|
|
|
if __name__ == "__main__":
|
|
import uvicorn
|
|
|
|
uvicorn.run(
|
|
"web.app:app",
|
|
host="0.0.0.0",
|
|
port=8000,
|
|
workers=int(os.getenv("UVICORN_WORKERS", "4")),
|
|
)
|