Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 41
Socketio
Beau Barker edited this page Jul 29, 2025
·
4 revisions
SocketIO server.
fromflaskimportFlask, Requestfromflask_socketioimportSocketIO, send# type: ignorefromjsonrpcserverimportResult, Success, dispatch, methodapp=Flask(__name__)
socketio=SocketIO(app)
@methoddefping() ->Result:
"""JSON-RPC method"""returnSuccess("pong")
@socketio.on("message") # type: ignoredefhandle_message(request: Request) ->None:
"""Handle SocketIO request"""ifresponse:=dispatch(request):
send(response, json=True)
if__name__=="__main__":
socketio.run(app, port=5000)Reference: JSON-RPC in flask_socketio.
Contributions are appreciated – simply hit Edit or New page.