[Twisted-web] CGI is not working on windows

Fabian Steiner lists at fabis-site.net
Sun Apr 9 07:04:58 CDT 2006


Hello!

I have written a very small HTTP-Server with CGI-support based on
twisted.web and twisted.web.twcgi. Everything works fine on Linux, but
whenever I want my twisted web server to serve a Python-CGI script on
Windows XP I get the following error: pywintypes.error: (193,
'CreateProcess', '%1 ist keine zul\xe4ssige Win32-Anwendung.')
<http://localhost:81/cgi-bin/request.py#tbend> (saying that %1 is not a
valid win32 application)

In fact, I don't know what I did wrong, my HttpServer.py looks like this:

import sys
from twisted.internet import reactor
from twisted.web import static, server, twcgi
import config

class HttpServer(object):
    def __init__(self, htdocs, directory_indexes=None):
        directory_indexes = None or directory_indexes
        self.HttpServer = static.File(htdocs)
        self.HttpServer.indexNames = ['index.html', 'index.htm',
'start.html', 'start.htm']
        if directory_indexes is not None:
            self.HttpServer.indexNames.extend([index_name for index_name
in directory_indexes])
        self.HttpServer.putChild('cgi-bin',
twcgi.CGIDirectory(config.CGI_DIR))
        self.HttpServer.processors = {'.py': PythonScript}
       
    def run(self, port):
        reactor.listenTCP(port, server.Site(self.HttpServer))
        reactor.run()
       
class PythonScript(twcgi.FilteredScript):
    filter =  r'"C:\Python24\python.exe -u"'

if __name__ == '__main__':
    http = HttpServer(config.HTDOCS_DIR)
    try:
        http.run(81)
    except:
        print 'Can\'t start server. Aborting!'
        sys.exit(1)
       

The Python-CGI-Script which should be served to the client is a simple
"Hello world!" script which runs in the console when called directly.

What did I do wrong? Any hints?

Cheers,
Fabian




More information about the Twisted-web mailing list