Giter Club home page Giter Club logo

weather-app's Introduction


Weather App

A Python-based command-line application to fetch and display weather information for a city using the OpenWeatherMap API. The application allows users to choose between viewing the current weather and a 5-day forecast.

Features

  • Fetch current weather data for a specified city.
  • Fetch 5-day weather forecast data for a specified city.
  • Display weather information in both metric and imperial units.
  • Interactive menu for selecting the type of weather information to display.

Requirements

  • Python 3.6 or higher
  • OpenWeatherMap API key

Installation

  1. Clone the repository or download the script.

  2. Install the required Python packages using pip:

    pip install -r requirements.txt
  3. Create a settings.ini file in the same directory as the script and add your OpenWeatherMap API key:

    [openweather]
    api_key = your_api_key_here

Usage

Run the script from the command line with the required arguments.

Command-Line Arguments

  • city (required): The name of the city for which you want to fetch the weather data.
  • -i, --imperial (optional): Display the temperature in imperial units (Fahrenheit).

Example

To get the current weather for London in metric units:

python app.py London

To get the current weather for New York in imperial units:

python app.py New York -i

Interactive Menu

After running the script, you will be presented with a menu to choose between viewing the current weather or the 5-day forecast:

Choose an option:
1. Current Weather
2. 5-Day Forecast
3. Exit
Enter your choice (1/2/3):

Enter 1 to view the current weather, 2 to view the 5-day forecast, or 3 to exit the program.

Functions

get_api_key()

Reads the API key from the settings.ini file.

read_user_cli_args()

Parses command-line arguments.

build_weather_query(base_url, city_input, imperial=False)

Builds the query URL for the OpenWeatherMap API.

get_weather_data(query_url)

Fetches weather data from the OpenWeatherMap API.

display_current_weather_data(data, imperial=False)

Displays the current weather data.

display_forecast_data(forecast_data, imperial=False)

Displays the 5-day weather forecast data.

License

This project is licensed under the MIT License. See the LICENSE file for details.


Make sure to replace your_api_key_here with your actual OpenWeatherMap API key when running the script.

weather-app's People

Contributors

dusty-31 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.