class engineio.ASGIApp(engineio_server, other_asgi_app=None, static_files=None, engineio_path='engine.io', on_startup=None, on_shutdown=None)

ASGI application middleware for Engine.IO.

This middleware dispatches traffic to an Engine.IO application. It can also serve a list of static files to the client, or forward unrelated HTTP traffic to another ASGI application.

Parameters:
  • engineio_server – The Engine.IO server. Must be an instance of the engineio.AsyncServer class.

  • static_files – A dictionary with static file mapping rules. See the documentation for details on this argument.

  • other_asgi_app – A separate ASGI app that receives all other traffic.

  • engineio_path – The endpoint where the Engine.IO application should be installed. The default value is appropriate for most cases. With a value of None, all incoming traffic is directed to the Engine.IO server, with the assumption that routing, if necessary, is handled by a different layer. When this option is set to None, static_files and other_asgi_app are ignored.

  • on_startup – function to be called on application startup; can be coroutine

  • on_shutdown – function to be called on application shutdown; can be coroutine

Example usage:

import engineio
import uvicorn

eio = engineio.AsyncServer()
app = engineio.ASGIApp(eio, static_files={
    '/': {'content_type': 'text/html', 'filename': 'index.html'},
    '/index.html': {'content_type': 'text/html',
                    'filename': 'index.html'},
})
uvicorn.run(app, '127.0.0.1', 5000)
async not_found(receive, send)

Return a 404 Not Found error to the client.