The following was a CGI experiment for finding out the IP address of a connecting client. This is committed for archival to be run under Python 2.5 or later versions.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | import os, Zcgi
def main():
text = '''<html>
\t<head>
\t\t<title>
\t\t\tWho am I?
\t\t</title>
\t</head>
\t<body>
\t\t<b>
\t\t\t'''
try:
text += 'You are ' + os.environ['REMOTE_ADDR'] + '.'
except:
text += 'I do not know.'
text += '''
\t\t</b>
\t</body>
</html>'''
Zcgi.print_html(text)
if __name__ == '__main__':
Zcgi.execute(main, 'cgi')
|
The Zcgi
module can be found in recipe 475112.