>>>>> Fred Atkinson <[email protected]> (FA) wrote:

>FA>    What is the function to obtain the client browser's IP
>FA> address?   

You mean in a web server?

The following should work (and was posted by me not long ago):

from os import getenv

ip = (getenv("HTTP_CLIENT_IP") or
      getenv("HTTP_X_FORWARDED_FOR") or
      getenv("HTTP_X_FORWARDED_FOR") or
      getenv("REMOTE_ADDR") or
      "UNKNOWN")

I use getenv() rather than environ[] to avoid exceptions.
-- 
Piet van Oostrum <[email protected]>
URL: http://pietvanoostrum.com [PGP 8DAE142BE17999C4]
Private email: [email protected]
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to