Is anyone using CGIHTTPServer on a non-Unix/Windows platform?

Mark Wright mwright at pro-ns.net
Mon Jun 18 16:52:34 EDT 2001


I'm having problems getting it to work.  I'm running python CGI
scripts using the execfile() part of CGIHTTPServer (i.e. !has_fork and
!has_popen2), and it works like a charm when I do a GET.  But when I
try to do a POST, the thing just hangs in telnet and I get the "Page
could not be displayed" error in IE and a blank page in Mozilla.

(Techinically, I am running on Windows, but I've commented out the
popen2() section due to text/binary file conversion issues.)

Is anyone else having this problem?  The following script is an
example of one that fails (but works fine in Apache):

import os
import sys
import cgi

# ----------------------------------------------------------------------
if __name__ == '__main__':

	# parse parameters
	form = cgi.FieldStorage()

	out_file = sys.stdout
	if os.environ['REQUEST_METHOD'] == 'POST':
		out_file.write('Content-Type: text/html\n\n')
		out_file.write("<html>\n")
		out_file.write("<head><title> Did this work? </title></head>\n")
		out_file.write("<body>\n")
#		keys = os.environ.keys()
#		keys.sort()
#		for key in keys:
#			out_file.write("<br>" + key + ':' + cgi.escape(os.environ[key]) +
\
#				'\n')
		out_file.write("Did this work?\n")
		out_file.write("</body></html>\n")

	else:
		out_file.write('Content-type: text/html\n\n')
		out_file.write("<html>\n")
		out_file.write("<head><title> Did this work? </title></head>\n")
		out_file.write("<body>\n")
		out_file.write(
			"""<form action="xyz.py" method="POST">
				<br> try this out
					<input type="submit" name="BtnTest" value="Test">
				</form>""")
		out_file.write("</body></html>\n")



More information about the Python-list mailing list