title: Python twisted render PHP
body: <p>On a web server generated with python twisted is possible to run php pages?</p>
  
  <p>Looking at documentation seems it is possible:
  <a href="http://twistedmatrix.com/documents/current/api/twisted.web.twcgi.CGIScript.html" rel="nofollow">http://twistedmatrix.com/documents/current/api/twisted.web.twcgi.CGIScript.html</a></p>
  
  <p>I'm stuck at this point, how can I render the files?</p>
  
  <pre><code>    class service(resource.Resource):
  def getChild(self, name, request):
      self._path = request.prepath[:]
                  # Is this an php
      elif request.prepath[0] == 'php':
          return _ShowPHP
  
      elif (len(self._path) != 1):
          _ServiceError.SetErrorMsg('Invalid path in URL: %s' % self._path)
          return _ServiceError
  </code></pre>
  
  <p>ShowPHP:</p>
  
  <pre><code>class ShowPHP(resource.Resource):
  
  isLeaf = True   # This is a resource end point.
  def render(self, request):
    #return "Hello, world! I am located at %r." % (request.prepath,)
  
    class PythScript(twcgi.FilteredScript):
      filter="/usr/bin/php"
      resource = static.File("php") # Points to the perl website
      resource.processors = {".php": ShowPHP} # Files that end with .php
      resource.indexNames = ['index.php']
  
  
  ############################################################
  _ShowPHP = ShowPHP()
  </code></pre>
  
  <p>but when point the browser to the php page got this:
  Request did not return a string</p>
  
  <p>Request:</p>
  
  <pre><code>    &lt;GET /php/index.php HTTP/1.1&gt;
  </code></pre>
  
  <p>Resource:</p>
  
  <pre><code>      &lt;service.ShowPHP instance at 0x2943878&gt;
  </code></pre>
  
  <p>Value:</p>
  
  <p>None</p>