summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRasmus Luha <rasmus.luha@gmail.com>2022-03-16 16:39:29 +0200
committerRasmus Luha <rasmus.luha@gmail.com>2022-03-16 16:39:29 +0200
commitbaeb9ef961eef425ef5c655d8fd4e4140bb1526f (patch)
treebde0445da63125987a55e372c3a56760ed2fca51
parent9536dc1dd3c16119ac719453894a5385f9983050 (diff)
API teams request
-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