bin/myip

21 lines
424 B
Plaintext
Raw Normal View History

2025-01-23 00:45:24 -06:00
#!/usr/bin/python3
2024-08-09 19:08:50 -05:00
"""
myip - Fetch and display public IP information from ipinfo.io
"""
2024-07-14 14:43:36 -05:00
import json
import requests
if __name__ == "__main__":
2024-08-09 19:08:50 -05:00
KEY_COLOR = "\033[92m"
END_COLOR = "\033[0m"
response = requests.get("https://ipinfo.io", timeout=60)
json_data = json.loads(response.text)
2024-07-14 14:43:36 -05:00
2024-08-09 19:08:50 -05:00
print()
2024-07-14 14:43:36 -05:00
for item in json_data:
2024-08-09 19:08:50 -05:00
print(f"- {KEY_COLOR}{item.title():<16}{END_COLOR} {json_data[item]}")