Showing IP address of a user...
Marnanel
usenet at marnanel.org
Tue Jul 29 16:54:55 EDT 2003
Fazer wrote:
> I was wondering how I can show an IP address of a person who visits a
> Python web-page? Would I have to use Environment variables to access
> Apache's server variables which hold such values like in PHP or what?
This is defined by the Common Gateway Interface, so it should be the
same across all HTTP servers. It's certainly going to work the same way
across all languages on the same HTTP server.
os.environ is your friend:
import os
print 'Content-Type: text/plain'
print
print os.environ['REMOTE_ADDR']
(<URL:http://hoohoo.ncsa.uiuc.edu/cgi/> has the specification of all the
environment variables, in case you need more.)
M
More information about the Python-list
mailing list