2026-03-13 08:15:27 +08:00
|
|
|
"""
|
2026-03-03 21:27:57 +08:00
|
|
|
PolyWeather Web Map API
|
|
|
|
|
~~~~~~~~~~~~~~~~~~~~~~~
|
|
|
|
|
FastAPI backend that reuses existing weather data collection and analysis modules.
|
|
|
|
|
Serves a Leaflet-based interactive map frontend.
|
|
|
|
|
"""
|
|
|
|
|
|
|
|
|
|
import os
|
2026-03-20 20:59:30 +08:00
|
|
|
import sys
|
2026-03-03 21:27:57 +08:00
|
|
|
|
2026-03-08 04:35:04 +08:00
|
|
|
_file_dir = os.path.dirname(os.path.abspath(__file__))
|
|
|
|
|
_root = os.path.dirname(_file_dir)
|
2026-03-03 21:27:57 +08:00
|
|
|
if _root not in sys.path:
|
|
|
|
|
sys.path.insert(0, _root)
|
2026-03-08 04:35:04 +08:00
|
|
|
if _file_dir not in sys.path:
|
|
|
|
|
sys.path.insert(0, _file_dir)
|
2026-03-03 21:27:57 +08:00
|
|
|
|
2026-03-20 22:16:13 +08:00
|
|
|
from web.analysis_service import ( # noqa: E402
|
|
|
|
|
_analyze,
|
|
|
|
|
_build_city_detail_payload,
|
|
|
|
|
_build_city_summary_payload,
|
|
|
|
|
)
|
2026-05-14 20:01:26 +08:00
|
|
|
from web.app_factory import create_app # noqa: E402
|
2026-03-08 12:59:45 +08:00
|
|
|
|
2026-05-14 20:01:26 +08:00
|
|
|
app = create_app()
|
2026-03-08 12:59:45 +08:00
|
|
|
|
2026-03-20 22:25:33 +08:00
|
|
|
__all__ = [
|
|
|
|
|
"app",
|
|
|
|
|
"_analyze",
|
|
|
|
|
"_build_city_detail_payload",
|
|
|
|
|
"_build_city_summary_payload",
|
|
|
|
|
]
|
|
|
|
|
|
2026-03-08 12:59:45 +08:00
|
|
|
|
2026-03-03 21:27:57 +08:00
|
|
|
if __name__ == "__main__":
|
|
|
|
|
import uvicorn
|
|
|
|
|
|
|
|
|
|
uvicorn.run(app, host="0.0.0.0", port=8000)
|