1lab/ard.py
2024-05-20 18:42:46 +03:00

23 lines
402 B
Python

import uvicorn
from serial import Serial
import threading
from fastapi import FastAPI
s=""
ser = Serial('COM6', 9600)
def pot():
global s
while True:
s = ser.read(1) # read up to one hundred bytes
th=threading.Thread(target=pot)
th.start()
app = FastAPI()
@app.get("/")
async def root():
return ("message", s)
if __name__ == "__main__":
uvicorn.run(app, port=10000)