SHOW:
|
|
- or go back to the newest paste.
| 1 | - | async def read_body(receive): |
| 1 | + | def read_body(receive): |
| 2 | body = b'' | |
| 3 | more_body = True | |
| 4 | ||
| 5 | while more_body: | |
| 6 | - | message = await receive() |
| 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 | - | async def app(scope, receive, send): |
| 12 | + | def app(scope, receive, send): |
| 13 | - | body = await read_body(receive) |
| 13 | + | body = read_body(receive) |
| 14 | - | await send({
|
| 14 | + | asyncio.run(send({
|
| 15 | 'type': 'http.response.start', | |
| 16 | 'status': 200, | |
| 17 | 'headers': [ | |
| 18 | [b'content-type', b'text/plain'], | |
| 19 | ] | |
| 20 | - | }) |
| 20 | + | })) |
| 21 | - | await send({
|
| 21 | + | asyncio.run(send({
|
| 22 | 'type': 'http.response.body', | |
| 23 | 'body': body, | |
| 24 | - | }) |
| 24 | + | })) |
| 25 |