我不是 python 扭曲的专家,请帮我解决我的问题,当我尝试路径时 getChild 没有调用localhost:8888/dynamicchild
。甚至将 isLeaf 作为 False 在我的资源中。
根据我的理解,当我尝试localhost:8888
它应该返回蓝页当然它正在发生但是当我尝试localhost:8888/somex
语句打印“getChild called”应该打印在屏幕上但现在它没有发生
from twisted.web import resource
from twisted.web import server
from twisted.internet import reactor
class MyResource(resource.Resource):
isLeaf=False
def render(self,req):
return "<body bgcolor='#00aacc' />"
def getChild(self,path,request):
print " getChild called "
r=resource.Resource()
r.putChild('',MyResource())
f=server.Site(r)
reactor.listenTCP(8888,f)
reactor.run()