A simple Python command-line application that fetches and displays real-time weather data using the OpenWeatherMap API. Users can search weather by city name or zip code, save and view favorite locations, reload their last search, and manage their saved locations.
- 🌆 Search weather by City Name or Zip Code
- 📊 View Temperature, Feels Like, Humidity, and Conditions
- ⭐ Save locations as Favorites
- 📂 Reload the Last Searched Location
- ❌ Delete favorite locations
- 🧠 Smart error handling and data persistence using JSON and text files
-
Clone the repository
git clone https://github.com/your-username/weather-cli-app.git cd weather-cli-app -
Set up your API key
- Open
config.py - Replace
Nonewith your OpenWeatherMap API key:def get_api_key(): return "your_api_key_here"
- Open
-
(Optional) Set units
- Set
"imperial"(°F) or"metric"(°C) inget_units().
- Set
-
Run the application
python main.py
- Favorites: Stored in
favorites.json - Last searched location: Stored in
last_location.txt
- Python 3.7+
- Internet connection
- A valid OpenWeatherMap API key
weather-cli-app/
│
├── main.py # Main CLI loop
├── weather.py # API request logic
├── config.py # API key & units
├── storage.py # File I/O for saved locations
├── favorites.json # Favorite locations (auto-created)
├── last_location.txt # Last searched location (auto-created)
└── README.md # You're here!
- Display additional weather metrics (wind, pressure)
- Auto-refresh weather at intervals
- Optional config file for customization
- Cross-platform packaging as an executable
Created by Daniel Jarvis
This project is open-source and free to use.