James Franco
James Franco

Reputation: 4706

Extracting the json post parameter from aiohttp POST Request

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 ?

Upvotes: 4

Views: 2607

Answers (1)

Andrew Svetlov
Andrew Svetlov

Reputation: 17376

body = yield from request.json()

Upvotes: 7

Related Questions