I have built a small test application using the
CGIHTTPServer module that works fine on its own, but when it is converted into
an exe with py2exe the executable works for html files but it seizes up and
hangs as soon as it is asked to run a python script as a cgi.
I am using python2.3 on Windows2000 with py2exe 0.5.4
clue #1: my firewall (ZoneAlarm) tells me that a new server wants to access
the local internet when it goes to run the .py cgi script - as if the
existing server is not re-entrant but trying to create a new copy of itself
to run the py code. One of the ponts of CGIHTTPServer is to be able to run
python scripts as its native cgi language, maybe this ability to act as a
python interpreter is interfered with by py2exe?
clue #2: when I compiled the python cgi script separately with
py2exe and called the resulting exe as the cgi form handler it works. Hmmm,
so this is a sort of workaraound, except that I would have to compile all my cgi
Can anyone point me to a fix, or suggest what I
might be doing wrong? Thanks!
the code for this is here:
=== web server: =========
# show how to be a standalone app web server
# read in a
local text file, then deliver it as a webpage
import string, os, sys
# start a webserver on
cgi_directories = ['./cgi-bin', '/cgi-bin', '/htbin']
httpd = BaseHTTPServer.HTTPServer(("", PORT),
print "serving at port %s "
===== cgi script =========
# called by tryme.html when submit button is clicked
print "Content-type: text/plain"
print "So you want to see the
o = open("testdata.txt",'r')
for line in
print "%s<br>" % line
print "That's all
print "Goodbye, World!"
====the html file that calls the cgi:
<!-- THIS WORKS
Welcome to the test program.<br>
Pick one of the choices and click
<input type = "radio" name = "view">View the
<input type = "radio" name = "done">All
<input type="submit" value="Try me out!"
of code ===========