A simple weather forecasting application built using Flask, SQLAlchemy, and OpenWeather API. Users can register, log in, and view weather forecasts for any city. The app displays current weather details, including temperature and description, and allows users to check the weather for the next 3 days.
-
User Authentication:
- Registration: Allows users to create an account.
- Login: Users can log in with their username and password.
- Logout: Users can log out of their account.
-
Weather Forecast:
- Users can input a city name to get weather data.
- Displays the current weather (temperature, description).
- Displays the weather forecast for the next 3 days (including daytime and nighttime temperatures).
-
Responsive Design: Built with Tailwind CSS for responsive design.
- Backend: Python, Flask
- Database: SQLite (SQLAlchemy)
- Weather API: OpenWeather API (or another free API if OpenWeather requires a subscription)
- Frontend: HTML, CSS, Tailwind CSS
- Environment Variables:
.envfile for configuration (e.g., API keys)
Ensure you have the following installed:
- Python 3.x
- pip (Python package installer)
- virtualenv (optional, for creating a virtual environment)
-
Clone this repository:
git clone https://github.com/your-username/weather-forecast-app.git cd weather-forecast-app -
Create a virtual environment (optional but recommended):
python3 -m venv venv source venv/bin/activate # On Windows: venv\Scripts\activate
-
Install dependencies:
pip install -r requirements.txt
-
Set up environment variables:
- Create a
.envfile in the root directory of your project. - Add the following lines to your
.envfile (replace with your actual credentials):WEATHER_API_KEY=your_openweather_api_key WEATHER_API_URL=https://api.openweathermap.org/data/2.5/forecast SECRET_KEY=your_secret_key DATABASE_URI=sqlite:///db.sqlite3
- Create a
-
Run the application:
python app.py
-
Access the app in your browser:
http://127.0.0.1:5000
-
Register:
- Visit the registration page to create an account by providing a username, full name, and password.
- If the username is already taken or passwords don't match, appropriate error messages will appear.
-
Login:
- Use the login page to log in with your username and password.
- After successful login, you’ll be redirected to the homepage.
-
Weather Forecast:
- Enter the city name in the input field and press "Get Weather".
- The app will display the current weather for that city, including temperature and description.
- Below that, the 3-day weather forecast will show the date, day name (e.g., Monday), and both daytime and nighttime temperatures.
-
Logout:
- Click on the "Logout" link in the navigation bar to log out of your account.
Feel free to fork this repository and submit pull requests for improvements or bug fixes. Please follow the code style used in the project.
This project is open-source and available under the MIT License.