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 scripts.
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
def startserver(PORT):
    # start a webserver on specified port#
    import CGIHTTPServer
    import BaseHTTPServer
    class Handler(CGIHTTPServer.CGIHTTPRequestHandler):
        cgi_directories = ['./cgi-bin', '/cgi-bin', '/htbin']
    httpd = BaseHTTPServer.HTTPServer(("", PORT), Handler)
    print "serving at port %s " %PORT
===== cgi script =========
# testdemo.py
# called by tryme.html when submit button is clicked
import cgi
formStorage= cgi.FieldStorage()
 view = formStorage['view'].value
print "Content-type: text/plain"
print "<html><body>"
if view=='on':
 print "So you want to see the data.<br>"
 o = open("testdata.txt",'r')
 for line in o:
  print "%s<br>" % line
 print "That's all folks!<br>"
 print "Goodbye, World!"
print "</body></html>"
====the html file that calls the cgi: ===
<h1>Testing CGIHTTPServer</h1>
<form action=http://localhost:92/cgi-bin/testdemo.py >
<form action=http://localhost:92/cgi-bin/testdemo.exe >
-- >
Welcome to the test program.<br>
Pick one of the choices and click "Try Me"<br>
<input type = "radio" name = "view">View the Data<br>
<input type = "radio" name = "done">All Done<br>
<input type="submit" value="Try me out!" name="send">
====================end of code ===========