File size: 1,384 Bytes
dfc542c
 
 
91a458d
dfc542c
 
 
 
 
 
 
 
 
 
 
 
 
 
d64edc6
dfc542c
 
 
 
d64edc6
dfc542c
22b9c3e
 
 
 
dfc542c
22b9c3e
 
 
d64edc6
 
 
 
 
 
 
 
 
 
 
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
from fastapi import FastAPI
import os
import sys
src_directory = os.path.abspath(os.path.join(os.path.dirname(__file__), "../..", "backend"))
sys.path.append(src_directory)
from modules import home_page

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

@app.get("/ShowAllCountries")
def display_countries():
    countries = home_page.display_countries(df)
    return countries

@app.get("/ShowContinentStats/{attribute}/{stat_type}")
def display_continent_stats(attribute:str, stat_type:str):
    continent_stats = home_page.continent_stat(df, attribute, stat_type)
    return continent_stats

@app.get("/ShowCountryStats/{attribute}/{stat_type}")
def display_country_stats(attribute : str, stat_type : str):
    country_stats = home_page.country_stat(df, attribute,stat_type)
    return country_stats

@app.get("/ShowContinentWiseData/{attribute}")
def display_cont_wise_stats(attribute : str):
    conts_stats = home_page.get_continent_wise_stat(df,attribute)
    return conts_stats

@app.get("/ShowCountryData/{country}/{attribute}")
def display_country_wise_stats(country : str, attribute : str):
    conts_stats = home_page.get_country_wise_stat(df, country, attribute)
    return conts_stats