Guest User

Untitled

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