本文整理汇总了Python中twisted.web.static.File.noisy方法的典型用法代码示例。如果您正苦于以下问题:Python File.noisy方法的具体用法?Python File.noisy怎么用?Python File.noisy使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类twisted.web.static.File
的用法示例。
在下文中一共展示了File.noisy方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: setup
# 需要导入模块: from twisted.web.static import File [as 别名]
# 或者: from twisted.web.static.File import noisy [as 别名]
def setup(self):
self.port = self.master.config.get('port', name=self.name)
self.webroot = self.master.config.get('root', name=self.name)
self.logpath = self.master.config.get('log', name=self.name)
# Creste the root object
root = File(self.webroot)
root.noisy = False
root.putChild('', Redirect('lumina.html'))
# List of resources that we want added
resources = {'rest/command': RestCommand(self),
'rest/info': RestInfo(self),
}
# Traverse all resources and add them to the tree. Add empty
# resources for the path elements between our resources and the root.
for (path, resource) in resources.items():
elements = path.split('/')
# Traverse the path and either append to an existing resource
# or add a new one.
base = root
for element in elements[:-1]:
res = base.getStaticEntity(element)
if res is None:
res = Resource()
res.noisy = False
base.putChild(element, res)
base = res # pylint: disable=redefined-variable-type
# Add our resource to the tree
base.putChild(elements[-1], resource)
# Create the site
self.site = Site(root, logPath=self.logpath)
self.site.noisy = False
self.master.reactor.listenTCP(self.port, self.site)
self.log.info("Logging access in {p}", p=self.logpath)
# Ready
self.status.set_GREEN()