Example in README.md doesn't work
myers opened this issue · 2 comments
myers commented
I did roughly this:
mkdir test-granian
cd test-granian
poetry init -q
poetry add granian
create main.py
async def app(scope, receive, send):
assert scope['type'] == 'http'
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!',
})
poetry run granian --interface asgi main:app
the first call to app is with a scope like {'type': 'lifespan', 'asgi': {'version': '3.0', 'spec_version': '2.3'}}
which trips the assert. Removing the assert allows it to work.
gi0baro commented
@myers that's the ASGI lifespan protocol call. Doesn't granian just raise a warning message and keep serving the app?
myers commented
Ok, thank you I see now. You get an Assertion error, but it still works. May I suggest you handle that lifespan
in some what that doesn't display an error? It is confusing if you are not aware of the differences between lifespan and http messages.