Simple Flask app that fetches live weather and forecast from OpenWeatherMap API.
Features
- Search weather by city
- Displays temperature, humidity and a short forecast
Setup
- Create a virtual environment and install dependencies:
python -m venv .venv
.\.venv\Scripts\Activate.ps1
pip install -r requirements.txt- Create a
.envfile with your OpenWeatherMap API key:
OPENWEATHER_API_KEY=your_api_key_here
FLASK_SECRET=change_this
- Run the app:
python app.pyThen open http://127.0.0.1:5000 in your browser.
Docker Compose
Create a .env file in the repo root (or edit the .env file provided) with your API key:
OPENWEATHER_API_KEY=your_openweather_api_key_here
FLASK_SECRET=change-this-secret
Start with docker compose:
docker compose up --buildStop and remove containers:
docker compose downNotes
- This example uses the free OpenWeatherMap endpoints. The forecast endpoint returns 5-day/3-hour data and the app shows a small slice of it.
Docker
Build the image from the repository root:
docker build -t weather-dashboard:latest .Run the container (map port 5000):
docker run --rm -it -p 5000:5000 -e OPENWEATHER_API_KEY=your_key_here weather-dashboard:latestThen open http://127.0.0.1:5000 in your browser.