Advertisement
Guest User

Untitled

a guest
Dec 5th, 2021
115
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.60 KB | None | 0 0
  1.  async def read_body(receive):            
  2.      body = b''
  3.      more_body = True
  4.  
  5.      while more_body:
  6.          message = await receive()
  7.          body += message.get('body', b'')
  8.          more_body = message.get('more_body', False)
  9.      return body
  10.  
  11.  
  12.  async def app(scope, receive, send):
  13.      body = await read_body(receive)
  14.      await send({
  15.          'type': 'http.response.start',
  16.          'status': 200,
  17.          'headers': [
  18.              [b'content-type', b'text/plain'],
  19.          ]
  20.      })
  21.      await send({
  22.          'type': 'http.response.body',
  23.          'body': body,
  24.      })
  25.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement