Esempio n. 1
0
 def get(self, domain):
     try:
         city = geo.get_city_by_domain(domain)
         if city:
             city['domain'] = domain
         response = dict(status='OK', data=city)
     except:
         response = dict(status='ERROR')
     self.set_header('Content-Type', 'application/json')
     self.write(json_encode(response))
Esempio n. 2
0
 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))
Esempio n. 3
0
 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))