We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
2 parents 1fda62d + 721bc9c commit 7eafe68Copy full SHA for 7eafe68
myip.py
@@ -0,0 +1,19 @@
1
+#!/usr/bin/env python3
2
+# -*- coding: utf-8 -*-
3
+
4
+import socket
5
+from urllib.request import urlopen
6
7
8
+def public_ip():
9
+ read_res = urlopen('http://ipecho.net/plain').read()
10
+ return read_res.decode('utf-8')
11
12
13
+def local_ip():
14
+ return socket.gethostbyname(socket.gethostname())
15
16
17
+if __name__ == "__main__":
18
+ print("Getting public and local IP...")
19
+ print("Public IP: {}\nLocal IP: {}".format(public_ip(), local_ip()))
0 commit comments