Nikos Skalis Nikos Skalis - 1 year ago 208
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':""}

Answer Source

ahh the data part is accessed like that

await request.json()

You can find this in official aiohttp docs

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download