Nikos Skalis Nikos Skalis - 1 month ago 6x
reST (reStructuredText) Question

aiohttp: how-to retrieve the data (body) in aiohttp server from requests.get

Could you please advise on the following?

On the localhost:8900 there is aiohttp server running

when i do a request like (using the python2 module requests) from python

requests.get("http://127.0.01:8900/api/bgp/show-route", data={'topo':"switzerland", 'pop':"zrh", 'prefix':""})

And there is a route defined in the aiohttp server

app.router.add_route("GET", "/api/bgp/show-route", api_bgp_show_route)

which is being handled like

def api_bgp_show_route(request):

The question is: how do i retrieve on server-side the data part of the request ? meaning
{'topo':"switzerland", 'pop':"zrh", 'prefix':""}


ahh the data part is accessed like that

await request.json()

You can find this in official aiohttp docs