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
> 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")
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'
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
> 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?
>>
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
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
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
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
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
10 matches
Mail list logo