Add modules/ip_address.py
This commit is contained in:
parent
23fc0d976a
commit
8fb51d7a53
11
modules/ip_address.py
Normal file
11
modules/ip_address.py
Normal file
|
@ -0,0 +1,11 @@
|
||||||
|
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}"
|
Loading…
Reference in a new issue