Skip to content

wasir-codes/weather-cli-app

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 

Repository files navigation

Weather CLI App

A command-line weather app built with Python that fetches real-time weather data from the OpenWeatherMap API.

Features

  • Current temperature and feels-like temperature
  • Humidity, wind speed, and visibility
  • Handles invalid city names gracefully
  • Handles no internet connection gracefully
  • API key stored securely in .env file

Tech Stack

  • Python 3.14
  • requests
  • python-decouple

Setup

  1. Clone the repository
git clone https://github.com/wasir-codes/fullstack-journey.git
cd week-05-06/weather_cli
  1. Create and activate virtual environment
python -m venv venv
venv\Scripts\activate
  1. Install dependencies
pip install -r requirements.txt
  1. Get a free API key from https://openweathermap.org

  2. Create a .env file in the project root

Write this line with your api key in the .env file:

API_KEY=your_api_key_here
  1. Run the app
python weather.py

Example Output

📍 Dhaka, BD 🌤 Overcast clouds 🌡 Temperature : 24.98°C (feels like 25.73°C) 💧 Humidity : 84% 💨 Wind speed : 2.2 m/s 👁 Visibility : 10.0 km

What I learned

  • How to use the requests library to call the OpenWeatherMap API, parse the JSON response, and extract nested fields like data['main']['temp'] and data['weather'][0]['description']
  • Handling multiple error cases as required - in this app (invalid city, no internet, timeout)
  • Learned why timeout=5 matters - without it, a slow server can hang your program indefinitely
  • Storing secrets securely using .env and python decouple
  • Setting up virtual environment(venv)

About

A command-line weather app built with Python and OpenWeatherMap API

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages