Monday, July 18, 2011

Python - Get IP address of server

# Get IP address of server
LOCAL_SERVER_IP = [ip for ip in socket.gethostbyname_ex(socket.gethostname())[2] if not ip.startswith("127.")][-1]
if not LOCAL_SERVER_IP:
    LOCAL_SERVER_IP = 'localhost'
treeutils.LOCAL_SERVER_IP = LOCAL_SERVER_IP # Tell treeutils the server address


http://www.velocityreviews.com/forums/t339971-get-the-ip-address-of-a-host.html

No comments:

Post a Comment