Socket.IO integration for Flask applications.
Socket.IO integration for Flask applications.
The following organizations are funding this project:
Socket.IO |
Add your company here! |
---|
Many individual sponsors also support this project through small ongoing contributions. Why not join them?
You can install this package as usual with pip:
pip install flask-socketio
from flask import Flask, render_template
from flask_socketio import SocketIO, emit
app = Flask(__name__)
app.config['SECRET_KEY'] = 'secret!'
socketio = SocketIO(app)
@app.route('/')
def index():
return render_template('index.html')
@socketio.event
def my_event(message):
emit('my response', {'data': 'got it!'})
if __name__ == '__main__':
socketio.run(app)