def get(self, ip_address): try: city = geo.get_city_by_ip_address(ip_address) if city: city['ip_address'] = ip_address response = dict(status='OK', data=city) except: response = dict(status='ERROR') self.set_header('Content-Type', 'application/json') self.write(json_encode(response))
def get(self): try: ip_address = self.get_remote_addr() logger.info('Remote IP address is: %s' % ip_address) city = geo.get_city_by_ip_address(ip_address) if city: city['ip_address'] = ip_address response = dict(status='OK', data=city) except: response = dict(status='ERROR') self.set_header('Content-Type', 'application/json') self.write(json_encode(response))