Compare commits

...

2 Commits

Author SHA1 Message Date
dd9b0c60d3 pretty print 2023-06-08 16:37:15 +02:00
1f7ae3959c json output 2023-06-08 16:33:37 +02:00

9
ip.py
View File

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