[Twisted-Python] Running php script on twisted server

Tux Attack tuxattack14 at gmail.com
Thu Feb 18 04:30:21 EST 2010


I am trying to run a php script on a webserver written in twisted.For that i
am using twcgi module.
Here is my code.
This is code for webServer.py ->


from twisted.internet import reactor
from twisted.web import static,script,twcgi,server
from twisted.python.log import startLogging
import sys

class PHPScript(twcgi.FilteredScript):

filter='/media/DATA/Documents/project-docs/twisted/twisted-programs/testPHP/twisted-php.py'

root=static.File('html_files')
root.indexNames=['index.php']
root.processors={'.php':twcgi.PHPScript}
site=server.Site(root)
reactor.listenTCP(8000,site)
startLogging(sys.stdout)
reactor.run()


And here is another file used in program twisted-php.py ->

#!/usr/bin/env python
> import os, sys, commands
> print "Content-type: text/html\n\n";
> command = 'php ' + sys.argv.pop(1)
> data = commands.getstatusoutput(command)
> print data[1]
>


Now my problem is if i try to acess some url like
http://localhost:8000/list.php then everything works fine but if i enter url
with parameters like http://localhost:8000/list.php?file=sample.txt then
twisted is not passing parameters after '?' to twisted-php.py
I verified this in twisted-php.py
Is there any way i can use such php scripts with parameters in twisted?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://twistedmatrix.com/pipermail/twisted-python/attachments/20100218/87373559/attachment.htm 


More information about the Twisted-Python mailing list