|
|
@ -9,21 +9,16 @@ def header():
|
|
|
|
|
|
|
|
|
|
|
|
def main():
|
|
|
|
def main():
|
|
|
|
params = cgi.FieldStorage()
|
|
|
|
params = cgi.FieldStorage()
|
|
|
|
out = {
|
|
|
|
|
|
|
|
"ip": None,
|
|
|
|
|
|
|
|
"country": None,
|
|
|
|
|
|
|
|
"continent": None,
|
|
|
|
|
|
|
|
"location": None
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
header()
|
|
|
|
header()
|
|
|
|
client_ip = os.environ["REMOTE_ADDR"]
|
|
|
|
client_ip = os.environ["REMOTE_ADDR"]
|
|
|
|
if(len(params) > 0):
|
|
|
|
if(len(params) > 0):
|
|
|
|
for key in params:
|
|
|
|
for key in params:
|
|
|
|
if key == "geo":
|
|
|
|
if key == "geo":
|
|
|
|
|
|
|
|
import json
|
|
|
|
gi = pygeoip.GeoIP('GeoLiteCity.dat')
|
|
|
|
gi = pygeoip.GeoIP('GeoLiteCity.dat')
|
|
|
|
geo_info = gi.record_by_addr(client_ip)
|
|
|
|
geo_info = gi.record_by_addr(client_ip)
|
|
|
|
geo_info['ip'] = client_ip
|
|
|
|
geo_info['ip'] = client_ip
|
|
|
|
print(geo_info)
|
|
|
|
print(json.dumps(geo_info))
|
|
|
|
else:
|
|
|
|
else:
|
|
|
|
print(client_ip)
|
|
|
|
print(client_ip)
|
|
|
|
|
|
|
|
|
|
|
|