Obtaining the remote ip address

Ben Finney bignose+hates-spam at benfinney.id.au
Tue Mar 28 09:15:51 CEST 2006

"Alvin A. Delagon" <adelagon at gmail.com> writes:

> I have a python cgi script running behind a CGI server which is also 
> built using python using CGIHTTPServer module. How can my cgi script 
> obtain the remote ip address?

The CGI specification lists a number of environment variables that are
set for the scrit receiving the request. The one you want is


Python makes environment variables available via the 'os.environ' map.


 \     "I cannot conceive that anybody will require multiplications at |
  `\    the rate of 40,000 or even 4,000 per hour ..."  -- F. H. Wales |
_o__)                                                           (1936) |
Ben Finney

More information about the Python-list mailing list