API¶
WebSockets¶
WebSocketMiddleware¶
-
class
flask_websockets.WebSocketMiddleware(wsgi_app, sockets_manager, socket_app=<class 'flask_websockets.WebSocketApp'>)¶
Application Globals¶
-
flask_websockets.ws¶ A namespace object that holds the currently active socket connection inside a
SocketContext.This is a
werkzeug.local.LocalProxy.
Useful Functions and Classes¶
-
flask_websockets.has_socket_context()¶
-
flask_websockets.patch_app_run(app)¶ This patches
flask.Flask.run()to a version which does not directly fail using WebSockets, to quickly test out Flask-Websockets. It does not support all features offlask.Flask.run()and is not recommended for production settings.For an alternative, please see
run(), which is similar but without the debugging capabilites and no reloading.Thanks @gmyers18, who provided the basic code here: https://github.com/heroku-python/flask-sockets/issues/48#issuecomment-301060798
-
flask_websockets.run(app, host='', port=5000)¶