From fd5117183f1241f8670d492c57ad39b54d8d44d1 Mon Sep 17 00:00:00 2001 From: Balaji-Ganesh Date: Wed, 14 Jun 2023 16:10:53 +0530 Subject: [PATCH] =?UTF-8?q?=E2=9A=97=EF=B8=8F=20#1=20Able=20to=20get=20the?= =?UTF-8?q?=20ultrasonic=20feed=20with=20FastAPI?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- System/ESP32_communicator/fastapi_as_api.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 System/ESP32_communicator/fastapi_as_api.py diff --git a/System/ESP32_communicator/fastapi_as_api.py b/System/ESP32_communicator/fastapi_as_api.py new file mode 100644 index 0000000..180e955 --- /dev/null +++ b/System/ESP32_communicator/fastapi_as_api.py @@ -0,0 +1,14 @@ +from fastapi import FastAPI +import asyncio +import websockets + +app = FastAPI() + +url = 'ws://192.168.157.165:82' + +@app.get('/collision-distance') +async def listen(): + async with websockets.connect(url) as ws: + while True: + msg = await ws.recv() + print("collsion distance: ", msg)