File size: 568 Bytes
4a88b6a
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
dee3cfb
 
70a30b1
 
4a88b6a
 
 
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
from fastapi import FastAPI
from pydantic import BaseModel

app = FastAPI()
current_command = None

class Command(BaseModel):
    action: str
    x: int
    y: int

@app.post("/send-command")
async def send_command(command: Command):
    global current_command
    current_command = command
    return {"status": "command_received"}

@app.get("/get-command")
async def get_command():
    return current_command

@app.get("/")
def home():
    return "welcome to our world!"

if __name__ == '__main__':
    import uvicorn
    uvicorn.run(app, host='0.0.0.0', port=8000)