import streamlit as st import requests from dotenv import load_dotenv import os # Load environment variables from .env file load_dotenv() # Get OpenWeatherMap API key from environment variables API_KEY = os.getenv('OPENWEATHERMAP_API_KEY') # Function to get weather data def get_weather(city): url = f"http://api.openweathermap.org/data/2.5/weather?q={city}&appid={API_KEY}&units=metric" response = requests.get(url) if response.status_code == 200: return response.json() else: return None # Function to get the appropriate weather icon def get_weather_icon(weather_description): if 'rain' in weather_description: return 'fa-cloud-showers-heavy' elif 'clear' in weather_description: return 'fa-sun' elif 'cloud' in weather_description: return 'fa-cloud' elif 'thunderstorm' in weather_description: return 'fa-bolt' elif 'snow' in weather_description: return 'fa-snowflake' else: return 'fa-smog' # Streamlit UI def main(): st.set_page_config(page_title="Current Weather App", page_icon=":sun_behind_rain_cloud:", layout="wide") st.markdown( """ """, unsafe_allow_html=True, ) st.markdown("