20 lines
419 B
Python
20 lines
419 B
Python
|
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)
|