Re: IP Address Function

2009-07-09 Thread Tim Roberts
Fred Atkinson wrote: > >I wonder why they don't just have a function to return it instead of >putting you through all of that? In CGI, EVERYTHING gets communicated through environment variables. That (and the stdin stream) is really the only option, since you get a new process for every reques

Re: IP Address Function

2009-07-09 Thread Piet van Oostrum
> Fred Atkinson (FA) wrote: >FA> On Wed, 08 Jul 2009 12:29:54 +0200, Piet van Oostrum >FA> wrote: >>> Something like: >>> >>> #! /usr/bin/env python >>> >>> import cgi >>> from os import getenv >>> >>> print "Content-type: text/html" >>> print >>> >>> ipaddr = (getenv("HTTP_CLIENT_IP")

Re: IP Address Function

2009-07-08 Thread Nobody
On Wed, 08 Jul 2009 20:53:12 -0700, Fred Atkinson wrote: >>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'

Re: IP Address Function

2009-07-08 Thread Fred Atkinson
On Wed, 08 Jul 2009 12:29:54 +0200, Piet van Oostrum 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_F

Re: IP Address Function

2009-07-08 Thread Piet van Oostrum
> Fred Atkinson (FA) wrote: >FA> On Tue, 07 Jul 2009 22:54:03 -0300, "Gabriel Genellina" >FA> wrote: >>> En Tue, 07 Jul 2009 22:45:24 -0300, Fred Atkinson >>> escribió: >>> Is there a Python function I can use to get the user's IP address so I can display it on his browser? >>

Re: IP Address Function

2009-07-08 Thread Fred Atkinson
On Tue, 07 Jul 2009 22:54:03 -0300, "Gabriel Genellina" wrote: >En Tue, 07 Jul 2009 22:45:24 -0300, Fred Atkinson >escribió: > >> 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 "brow

Re: IP Address Function

2009-07-07 Thread Gabriel Genellina
En Tue, 07 Jul 2009 22:45:24 -0300, Fred Atkinson escribió: 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. By example

Re: IP Address Function

2009-07-07 Thread Chris Rebert
On Tue, Jul 7, 2009 at 6:45 PM, Fred Atkinson wrote: >        Is there a Python function I can use to get the user's IP > address so I can display it on his browser? from socket import gethostname, gethostbyname ip = gethostbyname(gethostname()) Cheers, Chris -- http://blog.rebertia.com -- http

Re: IP Address Function

2009-07-07 Thread Tim Harig
On 2009-07-08, Fred Atkinson wrote: > Is there a Python function I can use to get the user's IP > address so I can display it on his browser? If you are using CGI you can get it from the REMOTE_ADDR environmental variable. -- http://mail.python.org/mailman/listinfo/python-list

IP Address Function

2009-07-07 Thread Fred Atkinson
Is there a Python function I can use to get the user's IP address so I can display it on his browser? Regards, Fred -- http://mail.python.org/mailman/listinfo/python-list