Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Extracting the json post parameter from aiohttp POST Request

Tags:

python

aiohttp

currently I do something like this

app.router.add_route('POST', '/foo/{par}', foo_test)

How can I extract the body of the POST from request

@asyncio.coroutine
def foo_test(request):
    body = request.content.read() #returns a generator

My question is how to extract the body from the generator returned ?

like image 230
James Franco Avatar asked Mar 11 '23 18:03

James Franco


1 Answers

body = yield from request.json()

like image 164
Andrew Svetlov Avatar answered Mar 23 '23 15:03

Andrew Svetlov



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!