Socket IO
9/24/23 requires 3.6+
pip install flask-socketio
pip install eventlet #seems to just use it if installedSetup
from flask import Flask, render_template
from flask_socketio import SocketIO
app = Flask(__name__)
app.config['SECRET_KEY'] = 'secret!'
socketio = SocketIO(app)
if __name__ == '__main__':
socketio.run(app)In factories can do
socketio = SocketIO()
# then
socketio.init_app(app, cors_allowed_origins="*")In other folder
If no namespace, uses global namespace
'message' and 'json' special events to listen to for unnamed events
Use
sendfor these sepcial events andemitfor custom
Rooms
all clients auto join a room with their
request.sidname
Send messages from a background function
Last updated