コード例 #1
0
                email_thread.start()


#Render our html.
@app.route('/')
def index():
    return render_template('index.html', **config)


#Tell SocketIO to listen to the user input.
@socketio.on('Changing values')
def value_change(message):
    #Change our config values depending on what message was sent to the server.
    config[message['key']] = float(message['data'])
    #Push the changes made back to the clients.
    socketio.emit('update value', {
        'key': message['key'],
        'value': message['data']
    })


if __name__ == '__main__':
    try:

        socketio.start_background_task(background_sensor_reading)
        socketio.run(app, host='0.0.0.0', use_reloader=False)
    except KeyboardInterrupt:

        print("Closing server...")
        alarm.cleanup()