fix: strip() doesn't work for some reason. do it manually

master
Yiao Shen 4 months ago
parent 9e0d995b3f
commit 4cefa3264f
Signed by: y266shen
GPG Key ID: D126FA196DA0F362
  1. 5
      server.py

@ -7,9 +7,10 @@ app = Flask(__name__)
@app.route("/")
def lux():
ser = serial.Serial('/dev/ttyACM0')
data = ser.readline()
# Remove trailing newline (for some reason strip() doesn't work)
data = str(ser.readline()).split("\\")[0]
if data:
l = float(data.split("=")[1].strip())
l = float(data.split("=")[1])
return str(l)
else:
return "error"

Loading…
Cancel
Save