diff options
Diffstat (limited to 'cgi')
-rw-r--r-- | cgi/GeoIP.dat | bin | 878459 -> 0 bytes | |||
-rw-r--r-- | cgi/GeoLite2-Country.mmdb | bin | 0 -> 3990267 bytes | |||
-rw-r--r-- | cgi/framework.py | 6 |
3 files changed, 4 insertions, 2 deletions
diff --git a/cgi/GeoIP.dat b/cgi/GeoIP.dat Binary files differdeleted file mode 100644 index b98993c..0000000 --- a/cgi/GeoIP.dat +++ /dev/null diff --git a/cgi/GeoLite2-Country.mmdb b/cgi/GeoLite2-Country.mmdb Binary files differnew file mode 100644 index 0000000..90c1146 --- /dev/null +++ b/cgi/GeoLite2-Country.mmdb 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): |