This Python application fetches and displays the current weather report for Kano, Nigeria using the OpenWeatherMap API. It features a colorful command-line output for enhanced readability.
- Real-time weather data for Kano, Nigeria
- Displays various weather metrics including temperature, humidity, wind speed, and more
- Converts temperature from Kelvin to Celsius
- Colorful command-line output for better visibility
- Error handling for API requests
- Uses environment variables for secure API key storage
- Python 3.6+
requests
librarypython-dotenv
librarycolorama
library
- Clone this repository or download the script.
- Install the required libraries:
pip install requests python-dotenv colorama
- Sign up for a free API key at OpenWeatherMap.
- Create a
.env
file in the same directory as the script with the following content:
OPENWEATHERMAP_API_KEY=your_api_key_here
Replace your_api_key_here
with your actual OpenWeatherMap API key.
Run the script from the command line:
python kano_weather_app.py
The application will display the current weather report for Kano, Nigeria in your console with colored output.
The output will be similar to the following, but with colors:
=== Weather Report for Kano, Nigeria ===
Date and Time: 2024-09-22 15:30:45
Weather: Clear (clear sky)
Temperature: 32.5°C
Feels Like: 31.2°C
Min Temperature: 32.5°C
Max Temperature: 32.5°C
Humidity: 12%
Pressure: 1015 hPa
Wind Speed: 3.6 m/s
Wind Direction: 90°
=====================================
The application includes error handling for API requests and will display appropriate error messages in red if it fails to fetch weather data.
To change the city or country, modify the CITY
variable in the script. For example:
CITY = "Lagos,NG"
You can also customize the colors by modifying the Fore
, Back
, and Style
parameters in the display_weather_report
function.
Contributions to this project are welcome. Feel free to fork the repository and submit pull requests, or open issues for any bugs or feature requests.
This project is open source and available under the MIT License.