Metadata-Version: 2.4
Name: python-weather-web
Version: 1.0.0
Summary: 真实可用的 Flask 天气应用：wttr.in 数据，完整保留原始 weather.html（渐变背景/三日预报含月出月落/晨跑建议/预警），支持任意城市搜索与中英文切换。
Author: Python Weather Web
License: MIT
Keywords: weather,flask,wttr.in,web,zh,en
Classifier: Development Status :: 5 - Production/Stable
Classifier: Framework :: Flask
Classifier: License :: OSI Approved :: MIT License
Classifier: Natural Language :: Chinese (Simplified)
Classifier: Natural Language :: English
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Requires-Python: >=3.8
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: flask>=3.0
Requires-Dist: requests>=2.28
Dynamic: license-file

# python-weather-web

A real, usable Flask weather web app. Data comes from [wttr.in](https://wttr.in) (no API key needed). The frontend is the **original `weather.html` preserved as-is**: gradient background that changes with the weather, 3-day forecast cards with sunrise/sunset/moonrise/moonset, morning-run suggestions, weather alerts, and a travel tip. On top of that: **search any city** and a **zh / EN toggle**.

## Install

```bash
pip install flask requests
```

## Run

```bash
python demo.py
# or:  python demo.py --city 北京 --lang zh --port 5000
```

Then open http://127.0.0.1:5000 — enter a city, hit 查询 / Search, switch 中 / EN.

## How it works

- `python_weather_web/weather.py` — fetches wttr.in and returns a JSON whose fields match the original `weather.json` exactly (`city, temp, feels, weather, humidity, wind_speed, wind_dir, pressure, visibility, precip, uv, max_rain_chance, max_wind_speed, copyright` + `forecast[].{date, max_temp, min_temp, weather_text, rain_chance, sunrise, sunset, moonrise, moonset}`). Chinese city names are mapped to wttr-friendly names (e.g. 西安 → XiAn) so it never matches a weird location. Falls back to offline demo data on network failure.
- `python_weather_web/server.py` — Flask app: `GET /` serves the page, `GET /api/weather?city=&lang=` returns the JSON.
- `python_weather_web/static/index.html` — the original page; only `fetch("./weather.json")` was changed to call `/api/weather`, plus the search box, 中/EN button, and a fix for the undeclared `tipText` variable. Everything else (CSS, dictionaries, run logic, field rendering) is untouched.

## Project layout

```
python-weather-web/
├── demo.py
├── pyproject.toml
├── requirements.txt
├── LICENSE
├── README.md
├── README_zh.md
└── python_weather_web/
    ├── __init__.py
    ├── weather.py
    ├── server.py
    └── static/
        └── index.html
```

## Notes

- Hourly rainfall: wttr.in's free API does not provide it, so the field shows "无降雨 / No rain" (this matches the original page's behavior).
- If the city is unknown, the backend returns the offline fallback so the UI never breaks.

## License

MIT
