Spaces:
Sleeping
Sleeping
import os | |
import sys | |
src_directory = os.path.abspath(os.path.join(os.path.dirname(__file__), "../..", "main")) | |
sys.path.append(src_directory) | |
import requests_app | |
import pandas as pd | |
def choose_data_view(st_interface): | |
data_view_options = [ | |
"Select an option", | |
"Show All Continents", | |
"Show All Countries", | |
"Show Continent Stats", | |
"Show Country Stats", | |
] | |
selected_option = st_interface.selectbox("Select Data to Display", data_view_options) | |
return selected_option | |
def choose_stat_to_view(st_interface): | |
stat_options = ["Select an option","highest","lowest"] | |
selected_option = st_interface.selectbox("Select Stat to Display", stat_options) | |
return selected_option | |
def choose_attribute_to_view(st_interface): | |
attribute_options = ["Select an option","Population", "Area"] | |
selected_option = st_interface.selectbox("Select Attribute to Display", attribute_options) | |
return selected_option | |
def display_contents(option, streamlit): | |
try: | |
cont = requests_app.get_api(option) | |
continents = streamlit.table(cont) | |
return continents | |
except Exception as e: | |
streamlit.error(f"An error occurred while processing the CSV: {e}") | |
def display_stats(streamlit,choosen_data): | |
clean_choosen_data = choosen_data.replace(" ", "") | |
attribute = choose_attribute_to_view(streamlit) | |
if attribute in ["Population","Area"] : | |
stat = choose_stat_to_view(streamlit) | |
if stat in ["highest" , "lowest"]: | |
option = f"{clean_choosen_data}/{attribute}/{stat}" | |
display_contents(option,streamlit) | |