callisto/modules/ip_address.py

12 lines
258 B
Python
Raw Normal View History

2025-05-16 15:39:31 +02:00
import socket
def get_ip():
try:
s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
s.connect(("8.8.8.8", 80))
ip = s.getsockname()[0]
s.close()
except Exception:
ip = "No Connection"
return f"IP: {ip}"