import streamlit as st import requests API_BASE_URL = "https://ezhil24-world-population-fastapi.hf.space" # Update with your actual FastAPI URL st.title("Population Statistics") # Fetch continents st.header("Continents") response = requests.get(f"{API_BASE_URL}/continents/") if response.status_code == 200: continents = response.json().get("continents", []) continent = st.selectbox("Select a Continent", continents) else: st.error("Failed to fetch continents") # Fetch statistics for selected continent if st.button("Get Statistics"): stats_response = requests.get(f"{API_BASE_URL}/continents/{continent}/") if stats_response.status_code == 200: st.json(stats_response.json()) else: st.error("Failed to fetch data")