예제 #1
0
#!/usr/bin/python

from flask import Flask, render_template
from flask_socketio import SocketIO
from communication import Communication

app = Flask(__name__)
app.config["SECRET_KEY"] = "RemoteLab"

socket = SocketIO(app)

port = Communication()
port.open("/dev/ttyUSB0")


@app.route("/")
def index():
    return render_template("index.html")


@socket.on("connect")
def clientConnected():
    sendState()


@socket.on("setLedState")
def setLedState(led, state):
    if state.lower() == "on":
        port.ledOn(led)
    else:
        port.ledOff(led)