当前位置: 首页>>代码示例>>Python>>正文


Python File.indexNames方法代码示例

本文整理汇总了Python中twisted.web.static.File.indexNames方法的典型用法代码示例。如果您正苦于以下问题:Python File.indexNames方法的具体用法?Python File.indexNames怎么用?Python File.indexNames使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在twisted.web.static.File的用法示例。


在下文中一共展示了File.indexNames方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: on_load

# 需要导入模块: from twisted.web.static import File [as 别名]
# 或者: from twisted.web.static.File import indexNames [as 别名]
    def on_load(self):
        self.config = self.server.config.web
        with open('./web/js/init.js', 'w') as f:
            port = self.config.web_interface_port2
            auth = self.config.auth_key
            f.write('var server_port = "%s";\n var auth_key = "%s"' % (port,
                                                                       auth))
        root = File('./web')
        root.indexNames = ['index.html']
        root.putChild('css', static.File("./web/css"))
        root.putChild('js', static.File("./web/js"))
        root.putChild('img', static.File("./web/img"))

        checker = PasswordDictChecker(self.config)
        realm = HttpPasswordRealm(root)
        p = portal.Portal(realm, [checker])

        credentialFactory = DigestCredentialFactory("md5",
                                                    "Cuwo Interface Login")
        protected_resource = HTTPAuthSessionWrapper(p, [credentialFactory])

        auth_resource = resource.Resource()
        auth_resource.putChild("", protected_resource)
        site = SiteOverride(auth_resource)

        reactor.listenTCP(self.config.web_interface_port1, site)
        self.web_factory = WebFactory(self)
        reactor.listenTCP(self.config.web_interface_port2,
                          WebSocketFactory(self.web_factory))
开发者ID:PrinzJuliano,项目名称:cuwo-scripts,代码行数:31,代码来源:web.py

示例2: main

# 需要导入模块: from twisted.web.static import File [as 别名]
# 或者: from twisted.web.static.File import indexNames [as 别名]
def main():
    config = ConfigParser.ConfigParser()
    config.read(os.path.expanduser('~/.b07'))
    api = b07.api.API(reactor,
                      config.get('ingress', 'email'),
                      config.get('ingress', 'password'))
    

    http_root = Redirect('https://localhost:{}/'.format(config.get('server', 'https_port')))
    http_factory = Site(http_root)
    http_endpoint = endpoints.serverFromString(reactor,
                                               'tcp:{}'.format(config.get('server', 'http_port')))
    http_endpoint.listen(http_factory)

    https_root = File(os.path.expanduser(config.get('server', 'web_root')))
    https_root.indexNames = ['index.html']
    https_factory = Site(https_root)
    https_endpoint = endpoints.serverFromString(reactor,
                                                'ssl:{}:privateKey={}:certKey={}'.format(config.get('server', 'https_port'),
                                                                                         os.path.expanduser(config.get('server', 'ssl_key')),
                                                                                         os.path.expanduser(config.get('server', 'ssl_cert'))))
    https_endpoint.listen(https_factory)

    wsfactory = Factory()
    wsfactory.protocol = WebSocketProtocol
    wss_endpoint = endpoints.serverFromString(reactor,
                                              'ssl:{}:privateKey={}:certKey={}'.format(config.get('server', 'wss_port'),
                                                                                       os.path.expanduser(config.get('server', 'ssl_key')),
                                                                                       os.path.expanduser(config.get('server', 'ssl_cert'))))
    wss_endpoint.listen(txws.WebSocketFactory(wsfactory))



    reactor.run()
开发者ID:drhinehart,项目名称:b07bot,代码行数:36,代码来源:server.py

示例3: on_load

# 需要导入模块: from twisted.web.static import File [as 别名]
# 或者: from twisted.web.static.File import indexNames [as 别名]
    def on_load(self):
        config = self.factory.config

        f = open('./web/js/init.js', 'w')
        f.write('var server_port = "%s"' % config.web_port2)
        root = File('./web')
        root.indexNames = ['index.html']
        root.putChild('css', static.File("./web/css"))
        root.putChild('js', static.File("./web/js"))
        root.putChild('img', static.File("./web/img"))

        reactor.listenTCP(config.web_port1, Site(root))
        self.web_factory = WebFactory(self.factory)
        reactor.listenTCP(config.web_port2, WebSocketFactory(self.web_factory))
开发者ID:cindyker,项目名称:cuwo,代码行数:16,代码来源:web.py

示例4: run

# 需要导入模块: from twisted.web.static import File [as 别名]
# 或者: from twisted.web.static.File import indexNames [as 别名]
    def run(self):
        text_entry = {"User": "ruppena", "Location": "Fribourg", "Name": "Udoo Temperature",
                      "Address": "Bvd de Perolles 90, 1700 Fribourg"}
        service = ZeroconfService(name="Temperature (a) - " + socket.gethostname(), port=self.__port, text=text_entry)
        service.publish()
        data = ''
        logging.info("Up and Running")

        root = File('.')
        root.indexNames = ['rest-documentation.html']
        $pathdef
        site = Site(root)
        #site.protocol = HTTPChannelHixie76Aware # needed if Hixie76 is to be supported
        reactor.listenTCP(self.__port, site)
        reactor.run()
开发者ID:aruppen,项目名称:xwotModelCompiler,代码行数:17,代码来源:rest-server.py

示例5: run_static

# 需要导入模块: from twisted.web.static import File [as 别名]
# 或者: from twisted.web.static.File import indexNames [as 别名]
def run_static(host='127.0.0.1', port=8000, path='.', inject=True):
    '''
    Run static file server, useful for local development, can also automatically
    inject bebop.js into index pages.
    '''
    root = File(os.path.abspath(path))
    root_dir = os.path.abspath(os.path.dirname(__file__))
    if inject:
        root.putChild('_bebop', File(os.path.join(root_dir, '../lib')))
        root.indexNames=['index.html','index.htm']
        root.processors = {
            '.html': BebopIndex,
            '.htm': BebopIndex,
        }
    factory = Site(root)
    reactor.listenTCP(port, factory, interface=host)
开发者ID:gilligan,项目名称:bebop,代码行数:18,代码来源:static.py

示例6: on_load

# 需要导入模块: from twisted.web.static import File [as 别名]
# 或者: from twisted.web.static.File import indexNames [as 别名]
    def on_load(self):
        self.config = self.server.config.web
        with open('./scripts/webpanel/assets/js/init.js', 'w') as f:
            port = self.config.websocket_port
            auth = self.config.auth_key
            f.write('var server_port = "%s";\nvar auth_key = "%s";' % (port,
                                                                       auth))
        root = File('./scripts/webpanel')
        root.indexNames = ['index.html']
        root.putChild('assets', static.File("./scripts/webpanel/assets"))

        checker = PasswordDictChecker(self.config)
        realm = HttpPasswordRealm(root)
        p = portal.Portal(realm, [checker])

        credentialFactory = DigestCredentialFactory("md5",
                                                    "Cuwo webpanel Login")
        protected_resource = HTTPAuthSessionWrapper(p, [credentialFactory])

        auth_resource = resource.Resource()
        auth_resource.putChild("", protected_resource)
        site = SiteOverride(auth_resource)

        reactor.listenTCP(self.config.web_panel_port, site)
开发者ID:Faulik,项目名称:cuwo-webpanel,代码行数:26,代码来源:webpanel.py

示例7: FormPage

# 需要导入模块: from twisted.web.static import File [as 别名]
# 或者: from twisted.web.static.File import indexNames [as 别名]
class FormPage(resource.Resource):
    def render_GET(self, request):
        return ''

    def render_POST(self, request):
        newdata = request.content.getvalue()
        print newdata
        return ''

def getPort():
    parser = argparse.ArgumentParser()
    parser.add_argument('--port', help='port to run server on', type=int)
    args = parser.parse_args()
    if args.port:
        return args.port
    else:
        return 8080
    

if __name__ == '__main__':
    root = File('../Site/.')
    root.indexNames = ['test.html']
    root.putChild('test', FormPage())
    root.putChild('time', TimeJson())
    root.putChild('rpc', abb())
    site = server.Site(root)
    
    reactor.listenTCP(getPort(), site)
    reactor.run()
开发者ID:hymm,项目名称:SnapSvgTest,代码行数:31,代码来源:server.py


注:本文中的twisted.web.static.File.indexNames方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。