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


Python web.StaticFileHandler类代码示例

本文整理汇总了Python中tornado.web.StaticFileHandler的典型用法代码示例。如果您正苦于以下问题:Python StaticFileHandler类的具体用法?Python StaticFileHandler怎么用?Python StaticFileHandler使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: initialize

 def initialize(self, **kwargs):
     if 'no_cache' in kwargs:
         self._no_cache = kwargs['no_cache']
         del kwargs['no_cache']
     else:
         self._no_cache = False
     StaticFileHandler.initialize(self, **kwargs)
开发者ID:dropmann,项目名称:silky,代码行数:7,代码来源:server.py

示例2: get_content

 def get_content(cls, abspath, start=None, end=None):
     if cls.is_html_path(abspath):
         html = open(abspath, 'r').read()
         html = html.replace('</body>', cls.SCRIPT_AND_END_OF_BODY)
         return html
     else:
         return StaticFileHandler.get_content(abspath, start, end)
开发者ID:flashhtml5,项目名称:PyF5,代码行数:7,代码来源:default.py

示例3: get_content_size

 def get_content_size(self):
     _, ext = os.path.splitext(self.absolute_path)
     if ext in SPECIAL_EXTENSIONS:
         content = self.__class__.get_content(self.absolute_path)
         return len(content)
     else:
         return StaticFileHandler.get_content_size(self)
开发者ID:Ju2ender,项目名称:PyF5,代码行数:7,代码来源:static.py

示例4: __init__

    def __init__(self):
        self.db = pymongo.Connection(port=settings.DB_PORT)[settings.DB_NAME]
        self.fs = GridFS(self.db)
        self.loader = Loader(
            os.path.join(ROOT_DIR, 'template'),
            autoescape=None,
            namespace={
                'static_url': lambda url: StaticFileHandler.make_static_url({'static_path': STATIC_DIR}, url),
                '_modules': ObjectDict({'Template': lambda template, **kwargs: self.loader.load(template).generate(**kwargs)}),
            },
        )

        router = TornadioRouter(ScribeConnection)
        router.app = self
        socketio = TornadoApplication(router.urls, app=self)
        self.connections = []

        class FooResource(Resource):
            def __call__(self, request):
                socketio(request)

            def __getitem__(self, name):
                return self

        Application.__init__(self, {
            '': HomeResource(self),
            'favicon.ico': StaticFileResource(os.path.join(STATIC_DIR, 'img', 'favicon.ico')),
            'sounds': EditsResource(self),
            'static': StaticFileResource(STATIC_DIR),
            'socket.io': FooResource(),
        })
开发者ID:alekstorm,项目名称:scribe,代码行数:31,代码来源:scribe.py

示例5: get

 def get(self, group, path):
     logging.info("Request for %s file %s" % (group, path))
     
     #check that requested file directory is in defined archives - note that group does not have the leading \ or / characters
     if os.path.normpath(group).startswith(self.portal_rel_path):
         self.root = self.portal_abs_path + os.path.sep
         group = relativePath(group[len(self.portal_rel_path):])
     elif os.path.normpath(group).startswith(self.report_rel_path):
         self.root = self.report_abs_path + os.path.sep
         group = relativePath(group[len(self.report_rel_path):])
     else:
         raise HTTPError(404, "Invalid file %s" % path)
     
     path = os.path.join(group, path)
     #disable caching or archive files
     self.set_header("Cache-control", "no-cache")        
     StaticFileHandler.get(self, path, include_body=True)
开发者ID:robertbetts,项目名称:Kew,代码行数:17,代码来源:report_index_handler.py

示例6: append_version

 def append_version(cls, path):
     # this version is cached on the StaticFileHandler class,
     # keyed by absolute filesystem path, and only invalidated
     # on an explicit StaticFileHandler.reset(). The reset is
     # automatic on every request if you set
     # static_hash_cache=False in TornadoApplication kwargs.
     version = StaticFileHandler.get_version(dict(static_path=settings.bokehjsdir()), path)
     return ("%s?v=%s" % (path, version))
开发者ID:A-Beltran,项目名称:bokeh,代码行数:8,代码来源:static_handler.py

示例7: get_content

 def get_content(cls, abspath, start=None, end=None):
     gc.collect()  # 在mp4内容的时候,如果刷新网页会导致10053错误,并且内存不能回收,这里粗暴处理一下
     if cls.is_html_path(abspath):
         html = open(abspath, 'r').read()
         html = html.replace('</body>', cls.SCRIPT_AND_END_OF_BODY)
         return html
     else:
         return StaticFileHandler.get_content(abspath, start, end)
开发者ID:no2key,项目名称:PyF5,代码行数:8,代码来源:static.py

示例8: get_content

 def get_content(cls, abspath, start=None, end=None):
     gc.collect()  # 在mp4内容的时候,如果刷新网页会导致10053错误,并且内存不能回收,这里粗暴处理一下
     _, ext = os.path.splitext(abspath)
     if ext in SPECIAL_EXTENSIONS:
         content = open(abspath, 'r').read()
         if ext in HTML_EXTENSIONS:
             return process_html(content)
         elif ext in CSS_EXTENSIONS:
             return process_css(content)
     return StaticFileHandler.get_content(abspath, start, end)
开发者ID:Ju2ender,项目名称:PyF5,代码行数:10,代码来源:static.py

示例9: append_version

 def append_version(cls, path):
     # This version is cached on the StaticFileHandler class,
     # keyed by absolute filesystem path, and only invalidated
     # on an explicit StaticFileHandler.reset(). The reset is
     # automatic on every request if you set static_hash_cache=False
     # in TornadoApplication kwargs. In dev mode rely on dev tools
     # to manage caching. This improves the ability to debug code.
     if settings.dev:
         return path
     else:
         version = StaticFileHandler.get_version(dict(static_path=settings.bokehjsdir()), path)
         return ("%s?v=%s" % (path, version))
开发者ID:digitalsatori,项目名称:Bokeh,代码行数:12,代码来源:static_handler.py

示例10: initialize

    def initialize(self):
        # return custom type directly. The browser will do the parsing
        self.custom_type = None

        uri = self.get_argument('uri')

        try:
            self.modgui = get_plugin_gui(uri)
        except:
            raise HTTPError(404)

        try:
            root = self.modgui['resourcesDirectory']
        except:
            raise HTTPError(404)

        return StaticFileHandler.initialize(self, root)
开发者ID:,项目名称:,代码行数:17,代码来源:

示例11: initialize

 def initialize(self):
     StaticFileHandler.initialize(self, os.path.join(os.path.dirname(__file__), "data"))
开发者ID:cms-dev,项目名称:tws,代码行数:2,代码来源:TranslationWebServer.py

示例12: get_absolute_path

 def get_absolute_path(cls, root, path):
     return StaticFileHandler.get_absolute_path(root, "")
开发者ID:menglanchen,项目名称:IoVision,代码行数:2,代码来源:resource.py

示例13: parse_url_path

    def parse_url_path(self, url_path):
        if not url_path or url_path.endswith('/'):
            url_path += 'index.html'

        return StaticFileHandler.parse_url_path(self, url_path)
开发者ID:Alternhuman,项目名称:snorky,代码行数:5,代码来源:server.py

示例14: initialize

 def initialize(self, path, default_filename=None, as_attachment=False):
     StaticFileHandler.initialize(self, path, default_filename)
     self._as_attachment = as_attachment
开发者ID:d42,项目名称:octoprint-fork,代码行数:3,代码来源:util.py

示例15: get

 def get(self):
     StaticFileHandler.get(self, 'sitemap.xml')
开发者ID:coldnight,项目名称:vlog,代码行数:2,代码来源:index.py


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