Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

37 строки
1.4KB

  1. import engineio
  2. class ASGIApp(engineio.ASGIApp): # pragma: no cover
  3. """ASGI application middleware for Socket.IO.
  4. This middleware dispatches traffic to an Socket.IO application. It can
  5. also serve a list of static files to the client, or forward unrelated
  6. HTTP traffic to another ASGI application.
  7. :param socketio_server: The Socket.IO server. Must be an instance of the
  8. ``socketio.AsyncServer`` class.
  9. :param static_files: A dictionary with static file mapping rules. See the
  10. documentation for details on this argument.
  11. :param other_asgi_app: A separate ASGI app that receives all other traffic.
  12. :param socketio_path: The endpoint where the Socket.IO application should
  13. be installed. The default value is appropriate for
  14. most cases.
  15. Example usage::
  16. import socketio
  17. import uvicorn
  18. sio = socketio.AsyncServer()
  19. app = engineio.ASGIApp(sio, static_files={
  20. '/': 'index.html',
  21. '/static': './public',
  22. })
  23. uvicorn.run(app, host='127.0.0.1', port=5000)
  24. """
  25. def __init__(self, socketio_server, other_asgi_app=None,
  26. static_files=None, socketio_path='socket.io'):
  27. super().__init__(socketio_server, other_asgi_app,
  28. static_files=static_files,
  29. engineio_path=socketio_path)