IP Address Function

Fred Atkinson fatkinson at mishmash.com
Wed Jul 8 23:53:12 EDT 2009


On Wed, 08 Jul 2009 12:29:54 +0200, Piet van Oostrum <piet at cs.uu.nl>
wrote:

>Something like:
>
>#! /usr/bin/env python
>
>import cgi
>from os import getenv
>
>print "Content-type: text/html"
>print
>
>ipaddr = (getenv("HTTP_CLIENT_IP") or
>      getenv("HTTP_X_FORWARDED_FOR") or
>      getenv("HTTP_X_FORWARDED_FOR") or
>      getenv("REMOTE_ADDR") or
>      "UNKNOWN")
>
>print ipaddr

That did it.  

I wonder why they don't just have a function to return it instead of
putting you through all of that?  

At any rate, it works.  

Regards, 




                                                      Fred 



More information about the Python-list mailing list