summaryrefslogtreecommitdiff
path: root/API
diff options
context:
space:
mode:
Diffstat (limited to 'API')
-rw-r--r--API/main.py26
1 files changed, 26 insertions, 0 deletions
diff --git a/API/main.py b/API/main.py
new file mode 100644
index 0000000..382cf69
--- /dev/null
+++ b/API/main.py
@@ -0,0 +1,26 @@
+from fastapi import FastAPI
+import pandas as pd
+import os
+
+# Making relative paths for the data
+relPathTeams = "../AllAboutData/Data/NBAteams.csv"
+relPathPlayers = "../AllAboutData/Data/Players/"
+
+app = FastAPI()
+
+@app.get("/teams")
+def teamsIntoDict():
+
+ # Getting the data from csv files and then converting into dict to be send out on get request
+ teamsDf = pd.read_csv(relPathTeams).to_dict()
+
+ teams_dict = {}
+ for el in range(len(teamsDf["name"])):
+ teams_dict.update({el+1 :
+ {"Abbreviation" : teamsDf["abbreviation"][el],
+ "Name" : teamsDf["name"][el],
+ "FullName" : teamsDf["full_name"][el],
+ "City" : teamsDf["city"][el],
+ "Conference" : teamsDf["conference"][el],
+ "Division" : teamsDf["division"][el]} })
+ return teams_dict