Get IP address of viewers in python
When a user opens my page, the PHP client is called on page load. The client turns to a python turner worker.
In this python worker script, I wanted to get the IP address of the users. I tried both
ip = ([(s.connect(('8.8.8.8', 80)), s.getsockname()[0], s.close())
for s in [socket.socket(socket.AF_INET, socket.SOCK_DGRAM)]][0][1])
and
urlopen('http://ip.42.pl/raw').read()
But this gives my server IP, not the user's IP.
+3
source to share