Skip to content
/ weather Public

This Python CLI application fetches and displays current weather (temperature) for cities worldwide, normalizing city names and converting temperatures to Celsius.

License

Notifications You must be signed in to change notification settings

sade6h/weather

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

28 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

☁️ Weather (OOP & dotenv)

Weather is a Python-based command-line application designed with object-oriented principles that fetches and displays real-time weather information for any city using OpenWeatherMap API. It’s modular, clean, and secure by keeping API keys outside the code.


🌦️ Project Overview

This app allows users to:

  • Get real-time weather updates by city name
  • Convert and display temperatures in Celsius
  • Handle errors gracefully (invalid city, network issues)
  • Securely manage API keys using environment variables (.env)
  • Easily extend functionality with OOP architecture

📌 Features

✅ Object-oriented design for maintainability and extensibility ✅ Real-time weather data from OpenWeatherMap API ✅ API key security via .env and python-dotenv ✅ Clear terminal output ✅ Modular code structure for easy upgrades (forecast, GUI, etc.) ✅ Minimal external dependencies


⚙️ Technologies Used

Technology Purpose
Python 3 Core programming language
requests HTTP requests to fetch API data
python-dotenv Load environment variables from .env
JSON (built-in) Parse API responses

🚀 Getting Started

🔨 Prerequisites

🧩 Installation

  1. Clone the repo:

    git clone https://github.com/sade6h/weather.git
    cd weather
  2. (Optional) Create and activate a virtual environment:

    python -m venv venv
    source venv/bin/activate   # On Windows: venv\Scripts\activate
  3. Install dependencies:

    pip install -r requirements.txt
  4. Create .env file in the project root with:

    API_KEY=your_openweathermap_api_key
    
  5. Run the app:

    python app.py

🧪 Example Output

Please enter the city name: Tehran
Tehran Temperature: 26.34°C

📁 Project Structure

weather/
├── app.py                # Main OOP app entry point
├── config.py             # API config constants
├── weather_service.py    # WeatherService class (API requests)
├── requirements.txt      # Dependencies list
├── .env.example          # Sample environment variables file
└── README.md             # This file

🚧 Roadmap

  • Add multi-day weather forecast
  • Add humidity, wind speed, and description display
  • Integrate IP-based location detection
  • Build GUI (tkinter, streamlit)
  • Add export (JSON/CSV) functionality
  • Add multilingual support

🤝 Contributing

Feel free to fork, modify, and submit pull requests! Make sure to create feature branches and describe your changes.


👨‍💻 Author

Developed by @sade6h ☕ Star ⭐ if you find it useful!


📜 License

This project is licensed under the MIT License.


⚠️ Note: Keep your .env file secret! Never push it to public repositories.

About

This Python CLI application fetches and displays current weather (temperature) for cities worldwide, normalizing city names and converting temperatures to Celsius.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages