-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
70 lines (57 loc) · 1.79 KB
/
main.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
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
from fastapi import FastAPI
from model import *
from database import *
from google.cloud.firestore import GeoPoint
from starlette.middleware.cors import CORSMiddleware
app = FastAPI()
app.add_middleware(
CORSMiddleware,
allow_origins=["*"],
allow_credentials=True,
allow_methods=["*"],
allow_headers=["*"]
)
@app.get("/room",response_model=List)
def get_rooms():
response = fetch_all_rooms()
return response
@app.get("/room/{room_name}",response_model=dict)
def get_room_by_name(room_name:str):
response = fetch_one_room(room_name)
return response
@app.post("/room",response_model=Room)
def post_room(room_name:str):
response = create_room(room_name)
return response
@app.delete("/room")
def delete_room(room_name):
response = remove_room(room_name)
return response
@app.post("/location")
def post_location(longitude:float,latitude:float,room_name:str):
response = create_location(room_name,latitude,longitude)
return response
@app.get("/location/{room_name}")
def get_locations(room_name:str):
response = fetch_locations(room_name)
return response
@app.get("/player/{room_name}")
def get_players(room_name:str):
response = fetch_players(room_name)
return response
@app.post("/player",response_model=Player)
def post_player(player:Create_player,room_name:str):
response = create_player(player.to_dict(),room_name)
return response
@app.post("/simple/location")
def post_location(location:Location):
response = create_simple_location(location.latitude,location.longitude)
return response
@app.get("/simple/location")
def get_locations():
response = fetch_simple_locations()
return response
@app.delete("/simple/location/{id}")
def delete_simple_location(id:str):
response = remove_simple_location(id)
return response