This Weather App API allows users to get current weather updates by entering the name of a city. It uses the WeatherAPI to fetch real-time weather data and displays it on a web page.
- Python
- Flask
- Requests library
In addition, it is recommended to use a virtual environment. Instructions for creating a virtual environment as well as installing flask can be found here https://flask.palletsprojects.com/en/3.0.x/installation/
-
Clone the repository
-
Install dependencies
pip install flask requests
-
Run the Flask Application
python app.py
The application will run on http://127.0.0.1:5000/ by default
-
Obtain a weatherAPI Key
Obtain an API key from WeatherAPI and replace the placeholder API key inget_current_weather
function. More information about th API can be found here https://www.weatherapi.com/docs/
api_key = 'your_api_key_here'
This HTML template is used to create the front-end of the application. It uses Flask's Jinja2 templating engine to display data.
This is the main Flask application file that handles routing and server-side logic.
This file contains the function to fetch weather data from the WeatherAPI.
- Open the web browser and navigate to http://127.0.0.1:5000/
- Enter the name of a city in the input field and click the "Find" button.
- The current weather information for the city will be displayed on the page.