An ASGI-compatible "
Hello, World!" application written in
Python: async def application(scope, receive, send): event = await receive() ... await send({"type": "websocket.send", ...}) Where: • Line 1 defines an asynchronous function named , which takes three parameters (unlike in WSGI which takes only two), , and . • is a containing details about current connection, like the protocol, headers, etc. • and are asynchronous callables which let the application receive and send messages from/to the client. • Line 2 receives an incoming event, for example, HTTP request or WebSocket message. The keyword is used because the operation is asynchronous. • Line 4 asynchronously sends a response back to the client. In this case, it is a WebSocket communication. == Web Server Gateway Interface (WSGI) compatibility ==