diff options
Diffstat (limited to 'cgi/framework.py')
-rw-r--r-- | cgi/framework.py | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/cgi/framework.py b/cgi/framework.py index 94f6f30..faea8d9 100644 --- a/cgi/framework.py +++ b/cgi/framework.py @@ -108,8 +108,10 @@ def getCountry(ip): if ":" in ip: return "v6" else: - import geoip - return geoip.country(ip) + import geoip2.database + with geoip2.database.Reader('GeoLite2-Country.mmdb') as reader: + response = reader.country(ip) + return response.country.iso_code def getHost(ip): |