An open API service indexing awesome lists of open source software.

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

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:
![image](https://github.com/user-attachments/assets/9ca3f10d-30e4-4df3-83b6-3d4bbf2741f8)
![image](https://github.com/user-attachments/assets/b3ebbb2d-620c-4b2f-86dd-2716e51bcc35)
![image](https://github.com/user-attachments/assets/48fbf31a-fec7-4098-8178-17adb57e8255)
![image](https://github.com/user-attachments/assets/0abb98d2-f69e-4f37-9974-d37f9849228c)
![image](https://github.com/user-attachments/assets/d5ecfa56-62fc-4a1f-aedd-cf49d56d69e9)
![image](https://github.com/user-attachments/assets/1d20b809-eab0-4ae8-92b7-71edff2b6b3f)

### 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.