Before running the app, ensure you have the following installed:
- Python 3.x
- Flask
- An account on WeatherAPI to obtain an API key.
-
Clone the repository:
git clone https://github.com/yourusername/weather-app.git cd weather-app -
Create a virtual environment (optional but recommended):
python3 -m venv venv source venv/bin/activate # For Linux/Mac venv\Scripts\activate # For Windows
-
Install the required Python packages:
pip install -r requirements.txt
-
Set up your WeatherAPI key:
- Create a
.envfile in the root directory and add your WeatherAPI key:
API_KEY=your_weatherapi_key - Create a
-
Run the Flask app:
python app.py
-
Access the app:
Open your browser and navigate to
http://127.0.0.1:5000/to see the weather app in action.
- Enter the name of a city in the input field.
- Click the "Get Weather" button.
- The app will display the current temperature, weather condition, humidity, and wind speed for the selected city.
- Flask: Python web framework used to build the backend.
- HTML/CSS/JavaScript: Frontend technologies for building a responsive and interactive UI.
- WeatherAPI: External API used for fetching real-time weather data.
- dotenv: To handle environment variables securely.
This project uses a .env file to store the WeatherAPI key. Make sure to add your API key in the following format:
