https://github.com/udityamerit/weather-forecasting-web-app
Weather Forecast web app
https://github.com/udityamerit/weather-forecasting-web-app
Last synced: about 1 month ago
JSON representation
Weather Forecast web app
- Host: GitHub
- URL: https://github.com/udityamerit/weather-forecasting-web-app
- Owner: udityamerit
- Created: 2024-04-26T03:32:29.000Z (over 1 year ago)
- Default Branch: master
- Last Pushed: 2024-08-22T17:41:08.000Z (about 1 year ago)
- Last Synced: 2024-11-08T12:09:41.027Z (11 months ago)
- Language: Python
- Homepage: https://weather-forecasting-web-app.streamlit.app/
- Size: 1.36 MB
- Stars: 2
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
### Introduction
Streamlit is an open-source app framework for Machine Learning and Data Science projects. It's a powerful tool to create web applications with minimal code. In this guide, we will build a weather forecasting web app using Streamlit and a weather API to fetch data.### Prerequisites
- Basic understanding of Python
- Knowledge of using APIs
- Streamlit library installed (`pip install streamlit`)
- Access to a weather API (like OpenWeatherMap or Weatherstack)### Key Weather Forecasting Terms
1. **Temperature**: The degree of hotness or coldness measured on a definite scale.
2. **Humidity**: The amount of water vapor in the air.
3. **Wind Speed**: The speed at which the wind is blowing.
4. **Pressure**: The force exerted by the atmosphere at a given point.
5. **Precipitation**: Any form of water - liquid or solid - falling from the sky, including rain, snow, sleet, and hail.
6. **Visibility**: The distance one can see as determined by light and weather conditions.
7. **Weather Condition**: Describes the state of the atmosphere, such as clear, cloudy, rainy, or snowy.### Steps to Create the Weather Forecasting Web App
#### 1. Set Up Your Environment
First, install Streamlit and requests libraries using pip:
```bash
pip install streamlit requests
```#### 2. Import Necessary Libraries
```python
import streamlit as st
import requests
```#### 3. Create the Main Function
```python
your logic
```#### 4. Run the App
Save the script as `weather_app.py` and run it using Streamlit:
```bash
streamlit run weather_app.py
```### Explanation of Code
1. **Setting Up**: Import Streamlit and requests libraries.
2. **Main Function**: `main()` handles the app's main logic, displaying the title, text input for city name, and a button to fetch weather data.
3. **API Call**: `get_weather()` function makes a GET request to the weather API with the provided city name and API key. It returns the weather data in JSON format if the request is successful.
4. **Displaying Data**: `display_weather()` function takes the JSON response and extracts relevant information (temperature, humidity, etc.), displaying it in a readable format using Streamlit.
### App looks like:





### Conclusion
By following these steps, you will have a functional weather forecasting web app using Streamlit. This app can be further enhanced by adding features like a 5-day forecast, charts for visualizing weather data, and user authentication for personalizing the experience.