2024-07-14 21:43:36 +02:00
|
|
|
#!/usr/bin/env python3
|
2024-08-10 02:08:50 +02:00
|
|
|
|
|
|
|
"""
|
|
|
|
myip - Fetch and display public IP information from ipinfo.io
|
|
|
|
"""
|
2024-07-14 21:43:36 +02:00
|
|
|
|
|
|
|
import json
|
|
|
|
|
|
|
|
import requests
|
|
|
|
|
|
|
|
if __name__ == "__main__":
|
2024-08-10 02:08:50 +02: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 21:43:36 +02:00
|
|
|
|
2024-08-10 02:08:50 +02:00
|
|
|
print()
|
2024-07-14 21:43:36 +02:00
|
|
|
for item in json_data:
|
2024-08-10 02:08:50 +02:00
|
|
|
print(f"- {KEY_COLOR}{item.title():<16}{END_COLOR} {json_data[item]}")
|