File size: 648 Bytes
14e8f62
 
45da93b
a470da8
 
45da93b
 
a470da8
45da93b
a470da8
45da93b
 
 
 
 
a470da8
45da93b
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# 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']}%")