I am trying to use flask and flask_sockets for a project. I don't understand the event model here and the lack of detailed documentation doesn't help either ? Can you explain to me, what exactly is happening so that I could use this effectively.
from flask import Flask
from flask_sockets import Sockets
app = Flask(__name__)
sockets = Sockets(app)
@sockets.route('/echo')
def echo_socket(ws):
# what is happening here ?
while True:
message = ws.receive()
ws.send(message)
@app.route('/')
def hello():
return 'Hello World!'
edit: I am rephrasing the question. So how does this format translate to the onconnect onmessage and onclose event handlers in other callback driven frameworks ?