-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
52 lines (43 loc) · 1.08 KB
/
main.py
File metadata and controls
52 lines (43 loc) · 1.08 KB
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
from fastapi import FastAPI, Request
from fastapi.middleware.cors import CORSMiddleware
app = FastAPI()
status = {}
F = {}
app.add_middleware(
CORSMiddleware,
allow_origins=["*"],
allow_credentials=True,
allow_methods=["*"],
allow_headers=["*"],
)
@app.get("/")
def home():
return {"Shaking Hands Overseas" : "API"}
@app.post("/servo")
def servo(Info: dict):
status["s1"] = Info["s1"]
status["s2"] = Info["s2"]
status["s3"] = Info["s3"]
status["s4"] = Info["s4"]
status["s5"] = Info["s5"]
return {'s1': status["s1"],
's2': status["s2"],
's3': status["s3"],
's4': status["s4"],
's5': status["s5"]
}
@app.post('/custom')
def custom(custom: dict):
F[0] = custom["F1"]
F[1] = custom["F2"]
F[2] = custom["F3"]
F[3] = custom["F4"]
F[4] = custom["F5"]
@app.get("/reciever")
def reciever():
return {'s1': status[F[0]],
's2': status[F[1]],
's3': status[F[2]],
's4': status[F[3]],
's5': status[F[4]]
}