import serial import requests ser = serial.Serial('/dev/ttyUSB0') while True: line = ser.readline() out = requests.post("http://localhost:3000/reply",data=line.decode()[:-1]) ser.close()