Rsnarsna's picture
Update app.py
dee3cfb verified
raw
history blame contribute delete
568 Bytes
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)