oshipka/oshipka/webapp/websockets_routes.py

18 lines
444 B
Python

from flask import render_template
from flask_socketio import emit
from oshipka.webapp import test_bp, socketio
@test_bp.route('/websockets')
def websockets():
return render_template("test/websockets.html")
@socketio.on('SYN')
def handle_my_custom_namespace_event(json):
print('SOCKETIO: rcvd SYN: {}'.format(json))
print('SOCKETIO: sending SYN-ACK')
emit("SYN-ACK", {"data": 'SYN-ACK'})
print('SOCKETIO: sent SYN-ACK')