WeatherBot / app.py
Samuelxm's picture
Update app.py
45da93b
raw
history blame contribute delete
648 Bytes
# initial draft on April 9, 2023
#------------------------------
import streamlit as st
import requests
API_KEY = '0dab07e2d2af0b9039f11cb7ae4cf66f'
BASE_URL = 'http://api.openweathermap.org/data/2.5/weather'
st.title('AHWeatherBot')
city = st.text_input('Enter a city name')
if city:
params = {'q': city, 'appid': API_KEY, 'units': 'metric'}
response = requests.get(BASE_URL, params=params)
data = response.json()
st.write(f"Current weather in {city}:")
st.write(f"Temperature: {data['main']['temp']}°C")
st.write(f"Feels like: {data['main']['feels_like']}°C")
st.write(f"Humidity: {data['main']['humidity']}%")