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