Hi,
as a small capabilities demo I coded the piece below to show how to use
Python for cgi'ing on localhost and it more or less does the trick :-).
However, I when I freeze it with py2exe, starting the resulting exe fires up
the server allright,
but fails execute cgi commands correctly (i.e. the expected output - let's
say from cgi.test()) - is no longer emitted to the browser...).
Is there some py2exe-magic I need to do that I don't know of? Something in
the code that prevents the frozen version to work?
Any pointers would be much appreciated...
Python 2.3.2 , Py2exe 0.4.2, Win XP
Here's the code...:
import CGIHTTPServer, BaseHTTPServer, SimpleHTTPServe r
import threading
import sys
port=8000
# nicked from the SimpleHTTPServe r test rig
def simple( HandlerClass = SimpleHTTPServe r.SimpleHTTPReq uestHandler
,ServerClass = BaseHTTPServer. HTTPServer):
"""
"""
base(HandlerCla ss, ServerClass)
# nicked from the BaseHTTPServer test rig
def base(HandlerCla ss = BaseHTTPServer. BaseHTTPRequest Handler,
ServerClass = BaseHTTPServer. HTTPServer, protocol="HTTP/1.0"):
"""
"""
server_address = ('localhost', port)
HandlerClass.pr otocol_version = protocol
try:
httpd = ServerClass(ser ver_address, HandlerClass)
sa = httpd.socket.ge tsockname()
print "Serving HTTP on", sa[0], "port", sa[1], "..."
httpd.serve_for ever()
except KeyboardInterru pt:
http.socket.clo se()
def RunServer(ready Event=None
,HandlerClass = CGIHTTPServer.C GIHTTPRequestHa ndler
,ServerClass = BaseHTTPServer. HTTPServer):
simple(HandlerC lass, ServerClass)
if readyEvent:
readyEvent.set( )
def main():
testServerReady = threading.Event ()
threading.Threa d(target=RunSer ver, args=(testServe rReady,)).start ()
testServerReady .wait()
if __name__ == '__main__':
main()
as a small capabilities demo I coded the piece below to show how to use
Python for cgi'ing on localhost and it more or less does the trick :-).
However, I when I freeze it with py2exe, starting the resulting exe fires up
the server allright,
but fails execute cgi commands correctly (i.e. the expected output - let's
say from cgi.test()) - is no longer emitted to the browser...).
Is there some py2exe-magic I need to do that I don't know of? Something in
the code that prevents the frozen version to work?
Any pointers would be much appreciated...
Python 2.3.2 , Py2exe 0.4.2, Win XP
Here's the code...:
import CGIHTTPServer, BaseHTTPServer, SimpleHTTPServe r
import threading
import sys
port=8000
# nicked from the SimpleHTTPServe r test rig
def simple( HandlerClass = SimpleHTTPServe r.SimpleHTTPReq uestHandler
,ServerClass = BaseHTTPServer. HTTPServer):
"""
"""
base(HandlerCla ss, ServerClass)
# nicked from the BaseHTTPServer test rig
def base(HandlerCla ss = BaseHTTPServer. BaseHTTPRequest Handler,
ServerClass = BaseHTTPServer. HTTPServer, protocol="HTTP/1.0"):
"""
"""
server_address = ('localhost', port)
HandlerClass.pr otocol_version = protocol
try:
httpd = ServerClass(ser ver_address, HandlerClass)
sa = httpd.socket.ge tsockname()
print "Serving HTTP on", sa[0], "port", sa[1], "..."
httpd.serve_for ever()
except KeyboardInterru pt:
http.socket.clo se()
def RunServer(ready Event=None
,HandlerClass = CGIHTTPServer.C GIHTTPRequestHa ndler
,ServerClass = BaseHTTPServer. HTTPServer):
simple(HandlerC lass, ServerClass)
if readyEvent:
readyEvent.set( )
def main():
testServerReady = threading.Event ()
threading.Threa d(target=RunSer ver, args=(testServe rReady,)).start ()
testServerReady .wait()
if __name__ == '__main__':
main()
Comment