Spaces:
Sleeping
Sleeping
LapStore
commited on
Commit
·
4a84fec
1
Parent(s):
95608ed
debug mqtt
Browse files
app.py
CHANGED
|
@@ -38,7 +38,7 @@ def main():
|
|
| 38 |
|
| 39 |
|
| 40 |
@app.post("/send-coordinates")
|
| 41 |
-
def receive_coordinates(payload: CoordinatesPayload,background_tasks: BackgroundTasks):
|
| 42 |
coords= payload.coords
|
| 43 |
state_= payload.state
|
| 44 |
duration= payload.duration
|
|
@@ -50,10 +50,11 @@ def receive_coordinates(payload: CoordinatesPayload,background_tasks: Background
|
|
| 50 |
traffic_lights = get_traffic_in_container(coords)
|
| 51 |
tl_ids = check_signals(traffic_lights)
|
| 52 |
if tl_ids:
|
|
|
|
| 53 |
for tl_id in tl_ids:
|
| 54 |
-
background_tasks.add_task(open_signal, tl_id, state_, duration,delay) #"EMR" # "ACC"
|
| 55 |
-
|
| 56 |
-
|
| 57 |
else:
|
| 58 |
return {"error": "No traffic signals found in database"+str(traffic_lights)}
|
| 59 |
|
|
|
|
| 38 |
|
| 39 |
|
| 40 |
@app.post("/send-coordinates")
|
| 41 |
+
async def receive_coordinates(payload: CoordinatesPayload,background_tasks: BackgroundTasks):
|
| 42 |
coords= payload.coords
|
| 43 |
state_= payload.state
|
| 44 |
duration= payload.duration
|
|
|
|
| 50 |
traffic_lights = get_traffic_in_container(coords)
|
| 51 |
tl_ids = check_signals(traffic_lights)
|
| 52 |
if tl_ids:
|
| 53 |
+
|
| 54 |
for tl_id in tl_ids:
|
| 55 |
+
#background_tasks.add_task(open_signal, tl_id, state_, duration,delay) #"EMR" # "ACC"
|
| 56 |
+
answer = await open_signal(tl_id, state_, duration,delay)
|
| 57 |
+
return {"answer": answer} # temp here
|
| 58 |
else:
|
| 59 |
return {"error": "No traffic signals found in database"+str(traffic_lights)}
|
| 60 |
|