app: add scheme eval socketio function

This commit is contained in:
Nicolò Balzarotti 2023-02-22 03:44:37 +01:00
parent 44c0272434
commit 44e62713c2
1 changed files with 6 additions and 0 deletions

6
app.py
View File

@ -88,6 +88,12 @@ def recipe():
def handle_new_client():
updateState()
@socketio.on('eval scheme')
def eval_scheme(code):
output = phasectrl.safe_eval(code, statemachine.env)
phasectrl.safe_eval(f'(notify "{output}")', statemachine.env)
socketio.emit('eval output', output)
@socketio.on('get sensors history')
def send_sensors_history(elements=1000):
socketio.emit('sensor history', sensors.get_history(elements))