Spaces:
Sleeping
Sleeping
| import streamlit as st | |
| # from front_end import request_response | |
| import requests | |
| # API_URL = "https://velmurugan1122-backend.hf.space" | |
| API_URL = "https://velmurugan1122-backend.hf.space" | |
| def get_response(end_point:str = None): | |
| response = requests.get(f"{API_URL}/{end_point}") | |
| return response.json() | |
| st.title("π World Population Dashboard") | |
| st.subheader("Get insights into global population statistics") | |
| choosen_option = st.selectbox("Select an option", ["select any","Continents", | |
| "Country","Continent Stats", "Country Stats"]) | |
| if choosen_option == "Continents": | |
| continents = get_response(choosen_option.lower()) | |
| cont = st.table(continents) | |
| if choosen_option == "Country": | |
| country = get_response(choosen_option.lower()) | |
| country_data = st.table(country) | |
| if choosen_option == "Continent Stats": | |
| option = choosen_option.replace(" ","_").lower() | |
| choosen_attribute = st.selectbox("Select an option",["Choose Attribute","Population","Area"]) | |
| if choosen_attribute in ["Population","Area"]: | |
| choosen_stat = st.selectbox("Select an option",["Choose Stat","highest","lowest"]) | |
| if choosen_stat in ["highest", "lowest"]: | |
| end_point = f"{option}/{choosen_attribute}/{choosen_stat}" | |
| continet_stats = get_response(end_point) | |
| cont_stats = st.table(continet_stats) | |
| if choosen_option == "Country Stats": | |
| option = choosen_option.replace(" ","_").lower() | |
| choosen_attribute = st.selectbox("Select an option",["Choose Attribute","Population","Area"]) | |
| if choosen_attribute in ["Population","Area"]: | |
| choosen_stat = st.selectbox("Select an option",["Choose Stat","highest","lowest"]) | |
| if choosen_stat in ["highest", "lowest"]: | |
| end_point = f"{option}/{choosen_attribute}/{choosen_stat}" | |
| continet_stats = get_response(end_point) | |
| cont_stats = st.table(continet_stats) | |