Skip to content

Commit 62eaf55

Browse files
authored
Create main.py
1 parent c0e028f commit 62eaf55

1 file changed

Lines changed: 52 additions & 0 deletions

File tree

main.py

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
from fastapi import FastAPI, Request
2+
from fastapi.middleware.cors import CORSMiddleware
3+
app = FastAPI()
4+
5+
status = {}
6+
F = {}
7+
8+
app.add_middleware(
9+
CORSMiddleware,
10+
allow_origins=["*"],
11+
allow_credentials=True,
12+
allow_methods=["*"],
13+
allow_headers=["*"],
14+
)
15+
16+
@app.get("/")
17+
def home():
18+
return {"Shaking Hands Overseas" : "API"}
19+
20+
@app.post("/servo")
21+
def servo(Info: dict):
22+
status["s1"] = Info["s1"]
23+
status["s2"] = Info["s2"]
24+
status["s3"] = Info["s3"]
25+
status["s4"] = Info["s4"]
26+
status["s5"] = Info["s5"]
27+
28+
return {'s1': status["s1"],
29+
's2': status["s2"],
30+
's3': status["s3"],
31+
's4': status["s4"],
32+
's5': status["s5"]
33+
}
34+
35+
@app.post('/custom')
36+
def custom(custom: dict):
37+
F[0] = custom["F1"]
38+
F[1] = custom["F2"]
39+
F[2] = custom["F3"]
40+
F[3] = custom["F4"]
41+
F[4] = custom["F5"]
42+
43+
44+
45+
@app.get("/reciever")
46+
def reciever():
47+
return {'s1': status[F[0]],
48+
's2': status[F[1]],
49+
's3': status[F[2]],
50+
's4': status[F[3]],
51+
's5': status[F[4]]
52+
}

0 commit comments

Comments
 (0)