【发布时间】:2018-08-18 05:46:08
【问题描述】:
我在 Python2.6 和 Twisted 15.0.0 上运行:
from twisted.python import usage
from twisted.web import resource, server, static
from twisted.application import internet
class Options(usage.Options):
optParameters = [
]
def makeService(options):
# this variation works
root_resource = static.File('/tmp')
# this variation doesn't
root_resource = resource.Resource()
root_resource.putChild("here", static.File('/tmp'))
site = server.Site(root_resource)
web_svc = internet.TCPServer(8000, site)
return web_svc
但是在升级到 Python3.7 和最新版本 (18.7.0) 之后,我在 http://localhost:8000/here 什么都得不到
没有这样的资源
没有这样的子资源。
找不到任何扭曲的文档或示例说明不同的方法。
补充:
它正在启动服务,否则我看不到上面的内容。
出于复制目的,twisted/plugins/my_plugin.py 看起来像:
from twisted.application.service import ServiceMaker
svc = ServiceMaker("TEST_ONE",
"svc",
"Service",
"tstsvc"
)
并执行:
twist tstsvc
【问题讨论】:
标签: python-3.x twisted twisted.web