Closed Jaymon closed 1 year ago
ASGIHandler
classSome notes I had open while messing with Daphne:
daphne -b 0.0.0.0 -p 4000 asgi:application
pip install daphne
request object:
args (1) =
(
0:
{
'type': "http",
'http_version': "1.1",
'method': "GET",
'path': "/foo/bar",
'raw_path': b'/foo/bar',
'root_path': "",
'scheme': "http",
'query_string': b'',
'headers':
[
0:
(
0: b'host',
1: b'localhost:4000'
),
1:
(
0: b'user-agent',
1: b'curl/7.58.0'
),
2:
(
0: b'accept',
1: b'*/*'
)
],
'client':
[
0: "127.0.0.1",
1: 33958
],
'server':
[
0: "127.0.0.1",
1: 4000
],
'asgi':
{
'version': "3.0"
}
}
)
From the docs:
Heard about this from here:
Check out Starlette, Uvicorn, or FastAPI to see how it is implemented. It looks like FastAPI depends on Starlette, and Starlette is using Anyio as an underlying library. This module: asgiref also looks useful.
The current reference server is Daphne: