在使用 python twisted 生成的 Web 服务器上可以运行 php 页面吗?
查看文档似乎是可能的: http: //twistedmatrix.com/documents/current/api/twisted.web.twcgi.CGIScript.html
我被困在这一点上,我该如何渲染文件?
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
显示PHP:
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()
但是当将浏览器指向 php 页面时得到这个:请求没有返回字符串
要求:
<GET /php/index.php HTTP/1.1>
资源:
<service.ShowPHP instance at 0x2943878>
价值:
没有任何