Compare commits
No commits in common. "dd9b0c60d3b663380debe16d0bf68726df04f9aa" and "7f6b5dda2123713bb1125fa6a20d67536f528d90" have entirely different histories.
dd9b0c60d3
...
7f6b5dda21
9
ip.py
9
ip.py
@ -9,16 +9,21 @@ 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(json.dumps(geo_info, indent=2))
|
print(geo_info)
|
||||||
else:
|
else:
|
||||||
print(client_ip)
|
print(client_ip)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user