๐ค๏ธ Project 04: Real-time Weather CLI
Difficulty: ๐ Professional
Description
Build a professional command-line weather application that fetches real-time weather data from the Open-Meteo API (free, no API key needed!) and displays it beautifully in the terminal. This project combines API consumption, decorators, type hinting, error handling, and testing.
Requirements
- Fetch current weather data for any city using the Open-Meteo geocoding + weather API
- Display temperature, humidity, wind speed, and weather condition
- Support multiple cities in a single query
- Cache API responses using a decorator to avoid repeated requests
- Use type hints throughout the codebase
- Handle network errors and invalid city names gracefully
- Display weather data in a formatted, visually appealing way
Concepts You'll Practice
- HTTP Requests (
urllibโ no external dependencies!) - Decorators (caching)
- Type Hinting
- Error Handling (network, API, data)
- JSON parsing
- String formatting and CLI design
Example Output
๐ค๏ธ WEATHER CLI
===============
Enter city name: Gaza
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ ๐ Gaza, Palestinian Territory โ
โ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฃ
โ ๐ก๏ธ Temperature: 28.3ยฐC โ
โ ๐ง Humidity: 65% โ
โ ๐จ Wind Speed: 12.5 km/h โ
โ โ๏ธ Condition: Clear sky โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
How to Run
cd projects/04_weather_cli
python solution.pyNote: This project uses the free Open-Meteo API โ no API key or sign-up required!
Bonus Challenges
- Add 5-day forecast display
- Add temperature unit conversion (ยฐC / ยฐF)
- Save favorite cities to a config file