Weather Application
This is a simple command-line weather application that retrieves weather information for a specified city using the OpenWeatherMap API.
Functionality
The application allows users to retrieve weather information for a specific city. It provides the following details:
- City name
- Country
- Temperature
- Weather description
Additionally, the user can specify optional flags to retrieve additional information:
-por--pressure: Get the atmospheric pressure data for the entered city.-hor--humidity: Get the humidity data for the entered city.
How we built it
Following are the Key Components of this application 1) Command-line Interface: Click is used to define the command-line interface. It allows users to specify the city for which they want weather information and provides optional flags for additional data such as pressure and humidity.
2) Data Retrieval: The get_data function sends a request to the API using the specified city and API key. It gets the data using the url built with get_url function in the application.
3) API Integration: The application interacts with the OpenWeatherMap API to retrieve weather data. It requires an API key, which is stored as an environment variable.
4) Data Display: The main function extracts relevant information from the JSON response, including city name, temperature, weather description, pressure, and humidity (if requested). It then prints this information to the console.
5) Output Styling: The application utilizes ANSI escape codes to apply styling to the output. Specifically, it uses reverse video (REVERSE) to highlight the location name and resets formatting (RESET) afterward.
Accomplishments that we're proud of and What we learned
I have built Python CLI application using argparse module, but this was my first time working with the Click module. I chose a different module because I really wanted to understand the difference between both of them. Working on it made me realize that I need to work on more complex applications to properly understand the actual difference but it was fun and refreshing to work with a new module.
I also worked with output styling for the first time. The styling used in my application is very simple and small, but I found it interesting and will work and understand more of it in the future.
What's next for weather-app
I have been working with CLI applications a lot and I would love to build these into something with a GUI. I am also interested in Web Development, so building a web application or maybe a mobile application will be what will be next in store for my weather application.
Built With
- click
- openweathermapapi
- python
- python-cli
Log in or sign up for Devpost to join the conversation.