hello world example #
async def app(scope, receive, send):
await send({
'type': 'http.response.start',
'status': 200,
'headers': [
[b'content-type', b'text/plain'],
]
})
await send({
'type': 'http.response.body',
'body': b'Hello, world!',
})
当前版本 ASGI 3.0 (2019-03-04)
ASGI application: coroutine application(scope, receive, send)
connection scope
information, 一个 dict, at least includes type
: http
, websocket
, lifespan
await receive
, 然后得到 event dict
await send(event dict)