Skip to content
Advertisement

How do I get the client IP of a Tornado request?

I have a RequestHandler object for incoming post()s. How can I find the IP of the client making the request? I’ve browsed most of RequestHandler‘s methods and properties and seem to have missed something.

Advertisement

Answer

RequestHandler.request.remote_ip (from RequestHandler’s instance)

you can inspect the response like:

...
class MainHandler(tornado.web.RequestHandler):
    def get(self):
        self.write(repr(self.request))
...
User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement