How to use the geoip2.compat.compat_ip_address function in geoip2

To help you get started, we’ve selected a few geoip2 examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github maxmind / GeoIP2-python / geoip2 / webservice.py View on Github external
def _response_for(self, path, model_class, ip_address):
        if ip_address != 'me':
            ip_address = str(compat_ip_address(ip_address))
        uri = '/'.join([self._base_uri, path, ip_address])
        response = requests.get(uri,
                                auth=(self._account_id, self._license_key),
                                headers={
                                    'Accept': 'application/json',
                                    'User-Agent': self._user_agent()
                                },
                                timeout=self._timeout)
        if response.status_code != 200:
            raise self._exception_for_error(response, uri)
        body = self._handle_success(response, uri)
        return model_class(body, locales=self._locales)