Extract IP from request in Python

I have a Pythonic HTTP server which should determine the IP address of the client. How do I do this in Python? Is there a way to get request headers and extract it from there?

PS: I am using WebPy.

+3
source share
2 answers

Use web.ctx:

class example:
    def GET(self):
        print web.ctx.ip

More here

+4
source

web.env.get ('REMOTE_ADDR')

+3
source

Source: https://habr.com/ru/post/1710221/


All Articles