Get local IP automatically

This commit is contained in:
drmext 2022-09-05 23:40:46 +00:00
parent b41f622cac
commit 09e4c7c6e7
No known key found for this signature in database
GPG Key ID: F1ED48FFE79A6961

View File

@ -1,4 +1,19 @@
ip = '127.0.0.1'
import socket
# https://stackoverflow.com/a/28950776
def get_ip():
s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
s.settimeout(0)
try:
s.connect(('10.254.254.254', 1))
IP = s.getsockname()[0]
except Exception:
IP = '127.0.0.1'
finally:
s.close()
return IP
ip = get_ip()
port = 8000
services_prefix = "/core"
verbose_log = True