-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdummy_rou_sch.py
38 lines (30 loc) · 950 Bytes
/
dummy_rou_sch.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
# GIROS-UPM 2024-12-05
# REMOTE DRIVER
#
# pip install "fastapi[standard]"
from fastapi import FastAPI, HTTPException
import uvicorn
import logging
from pydantic import BaseModel
from typing import List
import dummy_route
logging.basicConfig(level=logging.INFO)
# Modelo de la peticion
class RouteRequest(BaseModel):
veh_ID: str
priority: str
start: List[float]
end: List[float]
#Código del servidor REST
app = FastAPI()
@app.post("/getroute")
async def getroute(request: RouteRequest):
try:
logging.info(f"Received request: {request}")
#INSERTAR EN EL FICHERO dummy_route.py LA RUTA A DEVOLVER
response = dummy_route.route
return response
except Exception as e:
raise HTTPException(status_code=500, detail=str(e))
# Ejecución del servidor REST. Cambiar localhost y 8000 por la IP y puerto donde debe escuchar el servidor.
uvicorn.run(app, host="localhost",port=8000)