Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Weather CLI

A simple command-line app that fetches current weather for any city using the OpenWeatherMap API.

Features

  • Get real-time temperature, "feels like", humidity, wind speed, and weather condition for any city
  • Metric units (°C, m/s)
  • Handles common errors: invalid API key, city not found, timeouts, connection issues

Folder Structure

.
├── main.py       # App entry point
├── api_key       # Your OpenWeatherMap API key (plain text)
├── README.md
└── LICENSE

Setup

  1. Get an API key Sign up at openweathermap.org and grab a free API key.

  2. Add your API key Paste your api key in the api_key file (no quotes, no extra whitespace):

    your_api_key_here
    
  3. Install dependencies

    pip install requests

Usage

Run the app:

python main.py

You'll be prompted to enter a city name:

Enter a city: London

========================================
        WEATHER IN LONDON
========================================
🌡️  Temperature : 18.2°C
🤔 Feels Like  : 17.9°C
💧 Humidity    : 64%
💨 Wind Speed  : 3.6 m/s
☁️  Condition   : Scattered clouds
========================================

Error Handling

Scenario Message
Empty city input Error: City name cannot be empty.
Invalid API key Error: Invalid API key.
City not found Error: City '<city>' was not found.
Request timeout Error: Request timed out.
Connection failure Error: Could not connect to the server.
Other HTTP errors Error: Server returned status code <code>.

Notes

  • Keep your api_key file private — don't commit it to version control. Add it to .gitignore.
  • Temperature units are set to metric (Celsius) by default. Change units in main.py to imperial for Fahrenheit.

License

See LICENSE for details.