Spaces:
Sleeping
Sleeping
File size: 1,999 Bytes
dfc542c |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 |
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()
@app.get("/")
def display_data():
return df.to_csv()
@app.get("/ShowAllContinents")
def display_continents():
continents = home_page.display_continents(df)
return continents.tolist()
@app.get("/ShowAllCountries")
def display_countries():
countries = home_page.display_countries(df)
return countries.tolist()
@app.get("/ShowContinentwithHighestPopulation")
def display_cont_with_high_pop():
highest_pop = home_page.continent_with_highest_population(df)
return highest_pop
@app.get("/ShowContinentwithLowestPopulation")
def display_cont_with_high_pop():
lowest_pop = home_page.continent_with_lowest_population(df)
return lowest_pop
@app.get("/ShowCountrywithHighestPopulation")
def display_country_with_high_pop():
highest_pop = home_page.country_with_highest_population(df)
return highest_pop
@app.get("/ShowCountrywithLowestPopulation")
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)
|