forked from alyab0uzaid/eHacks2024
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapi.py
41 lines (33 loc) · 1.25 KB
/
api.py
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
from fastapi import FastAPI , requests
from pydantic import BaseModel
import GoogleAPI
from main import App
app = FastAPI()
@app.post("/receive_location/{lat}/{long}/{mode}") #receives binformatioon via post
async def receive_location(lat, long, mode): #def to get data in async
print("Received DATA , ""LOCATION_DATA.dict()")
print(lat, " ", long, " ", mode)
Location = GoogleAPI.get_nearby_places_with_distance(lat, long, 15)
#dict used to process data
if mode == "Gym" and GoogleAPI.places_info_list and GoogleAPI.places_info_list[0]['name'] == "Student Fitness Center":
return{
"Spotify URL" : "Here goes spotify URL",
"Location:" : Location[0],
}
elif mode == "Chill":
return {
"Spotpify URL" : "Here goes spotify URL",
"Location:" : Location[0],
}
elif mode == "Library" and GoogleAPI.places_info_list and GoogleAPI.places_info_list[0]['name'] == "Student Fitness Center":
return {
"Spotify URL" : "Here goes spotify URL",
"Location:" : Location[0],
}
@app.get("/")
async def root():
return
print("Running")
if __name__ == "__main__" :
import uvicorn
uvicorn.run(app,host="",port = 5000)