bin/myip
2024-08-09 19:08:50 -05:00

21 lines
428 B
Python
Executable File

#!/usr/bin/env python3
"""
myip - Fetch and display public IP information from ipinfo.io
"""
import json
import requests
if __name__ == "__main__":
KEY_COLOR = "\033[92m"
END_COLOR = "\033[0m"
response = requests.get("https://ipinfo.io", timeout=60)
json_data = json.loads(response.text)
print()
for item in json_data:
print(f"- {KEY_COLOR}{item.title():<16}{END_COLOR} {json_data[item]}")