How to get requester port on aiohttp.web

Viewed 37

I have a funtion to get ip address of requester.

async def remote(self,request):
    print(request.remote)
    return web.Response(text=str(request.remote), status=200)

I need to get the port of requester. How to do it ?

1 Answers

The answer could be found in official doc:

peername = request.transport.get_extra_info('peername')
if peername is not None:
    host, port = peername
Related