IP Address Function
fatkinson at mishmash.com
Wed Jul 8 04:55:29 EDT 2009
On Tue, 07 Jul 2009 22:54:03 -0300, "Gabriel Genellina"
<gagsl-py2 at yahoo.com.ar> wrote:
>En Tue, 07 Jul 2009 22:45:24 -0300, Fred Atkinson <fatkinson at mishmash.com>
>> Is there a Python function I can use to get the user's IP
>> address so I can display it on his browser?
>There is a long distance between "Python" and "browser" - you'll have to
>tell us what is in between the two.
I want to have a Web page come up (written in Python, cgi)
that returns the IP address of the browser (user's PC's IP address).
>By example, do you have a server and the user connects to it? is it
>running Python? how do you run the Python application?
>And why do you want to do that on the server side? Isn't easier to do that
>on the client side? What about proxies? NAT?
Yes. By CGI.
>If using CGI, look at the REMOTE_ADDR environment variable.
I did look at REMOTE_ADDR but I've been unable to figure out
the correct way to code it. I've tried a number of ways but I've been
Ideally, I'd like to store the brower's IP address in a string
and then print the string on the Web page from a Python CGI script.
More information about the Python-list