Created
June 1, 2018 12:42
-
-
Save Worm4047/f4563cc2ce25dfb30bcd38f612d1c398 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from flask import Flask, render_template | |
| from flask_socketio import SocketIO, emit | |
| app = Flask(__name__) | |
| socketio = SocketIO(app) | |
| values = { | |
| 'slider1': 25, | |
| 'slider2': 0, | |
| } | |
| @app.route('/') | |
| def index(): | |
| return render_template('index.html',**values) | |
| @socketio.on('connect') | |
| def test_connect(): | |
| emit('after connect', {'data':'Lets dance'}) | |
| @socketio.on('Slider value changed') | |
| def value_changed(message): | |
| values[message['who']] = message['data'] | |
| emit('update value', message, broadcast=True) | |
| if __name__ == '__main__': | |
| socketio.run(app, host='0.0.0.0') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment