mirror of
https://codeberg.org/hyperreal/bin
synced 2024-11-25 10:23:42 +01:00
Add myip
This commit is contained in:
parent
6257cfde0d
commit
bc2bb06d6f
28
myip
Executable file
28
myip
Executable file
@ -0,0 +1,28 @@
|
||||
#!/usr/bin/env python3
|
||||
#
|
||||
# myip - Fetch and display public IP information fro ipinfo.io
|
||||
|
||||
import json
|
||||
|
||||
import requests
|
||||
|
||||
|
||||
class bcolors:
|
||||
KEY = "\033[92m"
|
||||
ENDC = "\033[0m"
|
||||
|
||||
@staticmethod
|
||||
def colored(message: str, color: str):
|
||||
return color + message + bcolors.ENDC
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
req = requests.get("https://ipinfo.io")
|
||||
json_data = json.loads(req.text)
|
||||
|
||||
for item in json_data:
|
||||
print(
|
||||
"- {:<20} {}".format(
|
||||
bcolors.colored(item.title(), bcolors.KEY), json_data[item]
|
||||
)
|
||||
)
|
Loading…
Reference in New Issue
Block a user