37494a7192
将 web/routes.py 拆分为模块化 router + service 架构
- 新增 web/app_factory.py 集中注册 7 个域名 router
- 新增 web/routers/ 薄壳路由层(auth/city/system/scan/ops/payments/analytics)
- 新增 web/services/ 业务函数下沉(每域独立 service 文件)
- web/routes.py 缩减为 city_runtime 的兼容重导出 facade
- analysis_service.py/app.py 适配新入口并清理冗余导入
Scope-risk: LOW — 全量 170 测试通过,router 注册顺序与原路由一致
Tested: python -m pytest -q (170 passed), ruff check . (All checks passed)
@
39 lines
833 B
Python
39 lines
833 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(app, host="0.0.0.0", port=8000)
|