class api(tornado.web.RequestHandler):

    def initialize(self, *args, **kwargs):
        self.remote_ip = self.request.headers.get('X-Forwarded-For', self.
            request.headers.get('X-Real-Ip', self.request.remote_ip))
self.using_ssl = self.request.headers.get('X-Scheme', 'http') == 'https'

def get(self):
    self.write('Hello ' + ('s' if self.using_ssl else '') + ' ' + self.
        remote_ip)
Retrieve browser headers in Python