Team Ai
Datasetpublic

codekingpro/portable-devtools

sourceHugging Faceupdated 5mo agoView on Hugging Face
1likes14kdownloads
asgi.py48 linesDownload Raw Back to socketio
1import engineio2 3 4class ASGIApp(engineio.ASGIApp):  # pragma: no cover5    """ASGI application middleware for Socket.IO.6 7    This middleware dispatches traffic to an Socket.IO application. It can8    also serve a list of static files to the client, or forward unrelated9    HTTP traffic to another ASGI application.10 11    :param socketio_server: The Socket.IO server. Must be an instance of the12                            ``socketio.AsyncServer`` class.13    :param static_files: A dictionary with static file mapping rules. See the14                         documentation for details on this argument.15    :param other_asgi_app: A separate ASGI app that receives all other traffic.16    :param socketio_path: The endpoint where the Socket.IO application should17                          be installed. The default value is appropriate for18                          most cases. With a value of ``None``, all incoming19                          traffic is directed to the Socket.IO server, with the20                          assumption that routing, if necessary, is handled by21                          a different layer. When this option is set to22                          ``None``, ``static_files`` and ``other_asgi_app`` are23                          ignored.24    :param on_startup: function to be called on application startup; can be25                       coroutine26    :param on_shutdown: function to be called on application shutdown; can be27                        coroutine28 29    Example usage::30 31        import socketio32        import uvicorn33 34        sio = socketio.AsyncServer()35        app = socketio.ASGIApp(sio, static_files={36            '/': 'index.html',37            '/static': './public',38        })39        uvicorn.run(app, host='127.0.0.1', port=5000)40    """41    def __init__(self, socketio_server, other_asgi_app=None,42                 static_files=None, socketio_path='socket.io',43                 on_startup=None, on_shutdown=None):44        super().__init__(socketio_server, other_asgi_app,45                         static_files=static_files,46                         engineio_path=socketio_path, on_startup=on_startup,47                         on_shutdown=on_shutdown)48 
codekingpro/portable-devtools · Team Ai