This project utilizes the OpenWeatherMap Geocoding API to convert a city name to its corresponding latitude and longitude coordinates. It provides a simple way to retrieve the geographic information of a city using the OpenWeatherMap service.
Test.mp4
Before running this program, ensure you have the following prerequisites:
- Python 3 installed
- Django installed. If it is not installed run the below command.(Optional)
pip install django
- requests library installed (can be installed via pip install requests)
- Create a file called secret.py in the 'weather' directory. This file will contain the API key for the OpenWeatherMap API. The API key is stored in the variable API_KEY.
- An API key from OpenWeatherMap. You can sign up for a free account at OpenWeatherMap and obtain an API key.
To use this program, follow these steps:
-
Open the terminal and navigate to the directory where the main code file is located.
-
Run the following commands:
pip install -r requirements.txt # Update the localkeys.py file with your OpenWeatherMap API key. # Replace "Your API Key" with your actual API key. python manage.py runserver
This program includes the following features:
-
A user-defined function called get_key for 'secret.py' where the API key is stored in the variable API_KEY and returns the value of the API key to the main code.
def get_key(): API_KEY = "Your API Key" return API_KEY
-
The geocoding function is used to get the latitude and longitude of a given city.
-
The program utilizes the OpenWeatherMap API to retrieve weather data.
-
The program constructs the URL for the Weather API call and retrieves the response from it.
-
Exception handling is used to handle any key errors that may occur.
- Saksham Kumar (Polymath-Saksh)
- Aloukik Joshi (aloukikjoshi)
- Nihal Pandey (neurotoxin5060)
- Ankit Raj (ankitraj5670)
This project is licensed under MIT License - see the LICENSE file for details.
Copyright © to the contributing authors and the respective trademark owners.