[Twisted-web] [Twisted-Python]How to display python script output and php path

Normand Savard nsavard at mapgears.com
Wed Apr 5 08:54:40 CDT 2006

I'm using an existing twisted python script to serve my Web pages (see 
below) on Linux.  When I set the URL to point to a python script (see 
example below), the script executes well.  I see the output result in 
the shell window but nothing is shown in the browser window.  Could you 
point me out what is missing in this script to display the output of a 
script?  I looked in the mailing list archive and could not find my answer.

And how could I change the filter path to the php executable.  Actually 
the path is set to "/usr/bin/php4" and I want to set it to 



import sys
if sys.platform == 'win32':
    from twisted.internet import win32eventreactor
from twisted.python import log
from twisted.internet import reactor
from twisted.web import static, server, twcgi, script, xmlrpc, resource
from twisted.internet import utils
import os
import Interpreter
import Dispatcher
def main():
    print "Starting up Selenium Server..."
    root = resource.Resource()
    # The proxy server (aka "The Funnel")
    if sys.platform == 'win32':
        path = os.path.join(os.getcwd(),"cgi-bin","nph-proxy.exe")
        path = os.path.join(os.getcwd(),"cgi-bin","nph-proxy.cgi")
    proxy = twcgi.CGIScript(path)
    #The followoing are all available from /selenium-driver/
    #  * Selenium BrowserBot html, css, and javascript (/selenium-driver/*)
    #  * Selenese driver    (/selenium-driver/driver/)
    #  * XML-RPC listener   (/selenium-driver/RP2/)
    driver = static.File("./selenium_driver")
    driver.processors = {'.rpy': script.ResourceScript,
                         '.php': twcgi.PHPScript,
                         '.py': script.PythonScript}
    root.putChild('selenium-driver', driver)
    reactor.listenTCP(10001, server.Site(root))
if __name__ == '__main__':

Example of script:

#!/usr/bin/env python
print 'Allo'

More information about the Twisted-web mailing list