jabela

simpledashboard

Feb 14th, 2026 (edited)
54
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.36 KB | None | 0 0
  1. import socket
  2.  
  3. def get_local_ip():
  4.     s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
  5.     try:
  6.         # This does not send data, it just determines the active interface
  7.         s.connect(("8.8.8.8", 80))
  8.         ip = s.getsockname()[0]
  9.     finally:
  10.         s.close()
  11.     return ip
  12.  
  13. if __name__ == "__main__":
  14.     print("Local IP:", get_local_ip())
  15.  
Advertisement
Add Comment
Please, Sign In to add comment