Spaces:
Sleeping
Sleeping
from fastapi import FastAPI | |
import os | |
import sys | |
src_directory = os.path.abspath(os.path.join(os.path.dirname(__file__), "../..", "world_data_insights_api")) | |
sys.path.append(src_directory) | |
from modules import home_page | |
from api.schema import CountryDetails | |
from utils import logger | |
app = FastAPI() | |
df = home_page.process_data() | |
def display_data(): | |
return df.to_csv() | |
def display_continents(): | |
continents = home_page.display_continents(df) | |
return continents.tolist() | |
def display_countries(): | |
countries = home_page.display_countries(df) | |
return countries.tolist() | |
def display_cont_with_high_pop(): | |
highest_pop = home_page.continent_with_highest_population(df) | |
return highest_pop | |
def display_cont_with_high_pop(): | |
lowest_pop = home_page.continent_with_lowest_population(df) | |
return lowest_pop | |
def display_country_with_high_pop(): | |
highest_pop = home_page.country_with_highest_population(df) | |
return highest_pop | |
def display_country_with_high_pop(): | |
lowest_pop = home_page.country_with_lowest_population(df) | |
return lowest_pop | |
# highest_pop = home_page.display_countries(df).tolist() | |
# print(type(highest_pop)) | |
# @app.get("/") | |
# def home(): | |
# return end_points.welcome_msg() | |
# @app.get('/{continent}') | |
# def present_countries(continent : str): | |
# return home_page.list_country_by_continent(df, continent) | |
# @app.get("/{continent}/{data_type}/{stat}") | |
# def get_stats_of_cont(continent:str, data_type : str, stat:str): | |
# return home_page.get_stat_by_continent(df,continent,data_type,stat) | |
# @app.get("/{key}/{value}") | |
# def get_stats_of_cont(key : str ,value : str): | |
# return home_page.get_continent_with_max_value(df, key, value) | |