Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def read_body(receive):
- body = b''
- more_body = True
- while more_body:
- message = asyncio.run(receive())
- body += message.get('body', b'')
- more_body = message.get('more_body', False)
- return body
- def app(scope, receive, send):
- body = read_body(receive)
- asyncio.run(send({
- 'type': 'http.response.start',
- 'status': 200,
- 'headers': [
- [b'content-type', b'text/plain'],
- ]
- }))
- asyncio.run(send({
- 'type': 'http.response.body',
- 'body': body,
- }))
Advertisement
Add Comment
Please, Sign In to add comment