Get real-time weather information for any city with this sleek Python-based Weather Conditions App. This project includes both a command-line interface and a web application built with Flask. Simply enter a city name and receive current temperature, "feels like" temperature, and weather description!
- Real-time weather data from OpenWeatherMap API
- Temperature in Celsius
- "Feels like" temperature
- Current weather description
- Error handling for invalid city names
- Web interface using Flask
- Command-line interface option
-
Set up your environment:
Make sure you have Python installed on your system. -
Obtain an API Key:
Sign up on OpenWeather and get your free API key. -
Set up your environment variables:
Create a.env
file in the project directory and add your API key like this:API_KEY=your_openweather_api_key
-
Install dependencies:
Run the following command to install the necessary packages:pip install -r requirements.txt
-
Run the App:
-
For the web application, execute:
python main.py
Then open a web browser and go to
http://localhost:8000
. -
For the command-line interface, run:
python weather_app.py
Enter the name of a city when prompted to get the current weather.
-
We use Flask to create a web interface for the weather app:
@app.route('/weather')
def get_weather():
city = request.args.get('city')
weather_data = get_current_weather(city)
# ... process and render data
The weather_app.py
script can be run directly for a CLI experience:
if __name__ == '__main__':
city_name = input("Please, enter a city name: ")
weather_data = get_current_weather(city_name)
# ... display weather information
We use Waitress as a production WSGI server:
from waitress import serve
if __name__ == "__main__":
serve(app, host="0.0.0.0", port=8000)
- Add support for forecasting weather data.
- Implement caching to reduce API calls for frequently requested cities.
- Add user authentication to allow saving favorite cities.
- Implement a responsive design for better mobile experience.
Khaled Soudy
This project is licensed under the MIT License. See the LICENSE file for details.
Contributions are welcome! Please feel free to submit a Pull Request.
This project's dependencies are listed in the requirements.txt
file. Key dependencies include:
- Flask
- Requests
- Python-dotenv
- Waitress
If you encounter any problems or have any questions, please open an issue in the GitHub repository.
Stay informed about the weather conditions in any city, anytime! ☀️🌧️❄️