webug/websocket.py

20 lines
419 B
Python
Raw Normal View History

2019-12-14 19:07:29 +01:00
import json
from flask_socketio import emit
from objects import display
from objects import glob
@glob.websocket.on("connect")
def ws_connect():
emit("msg", "hi")
@glob.websocket.on("display")
def ws_display(data):
def handle_list(_):
emit("display", {"action": "list", "value": list( display.displays.keys() )})
switch = {
"list": handle_list
}
switch.get(data["action"])(data)