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


Python static.serve_file方法代码示例

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


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

示例1: download

# 需要导入模块: from cherrypy.lib import static [as 别名]
# 或者: from cherrypy.lib.static import serve_file [as 别名]
def download(self, **args):
        args = self.clean_args(args)
        filepath = self.getDownload(args)

        if type(filepath).__name__ == "str":
            return serve_file(filepath, "application/x-download", "attachment", name='data.csv')
        if type(filepath).__name__ == "instance":
            file_obj = serve_fileobj(
                filepath.getvalue(),
                "application/x-download",
                "attachment",
                name='data.csv'
            )
            return file_obj
        if type(filepath).__name__ == "StringIO":
            file_obj = serve_fileobj(
                filepath.getvalue().encode('utf-8'),
                "application/x-download",
                "attachment",
                name='data.csv'
            )
            return file_obj
        else:
            return "error downloading file. filepath must be string of buffer" 
开发者ID:adamhajari,项目名称:spyre,代码行数:26,代码来源:server.py

示例2: download

# 需要导入模块: from cherrypy.lib import static [as 别名]
# 或者: from cherrypy.lib.static import serve_file [as 别名]
def download(self):
        path = os.path.join(absDir, 'pdf_file.pdf')
        return static.serve_file(path, 'application/x-download',
                                 'attachment', os.path.basename(path)) 
开发者ID:cherrypy,项目名称:cherrypy,代码行数:6,代码来源:tut09_files.py

示例3: error_page_404

# 需要导入模块: from cherrypy.lib import static [as 别名]
# 或者: from cherrypy.lib.static import serve_file [as 别名]
def error_page_404(status, message, traceback, version):
    path = os.path.join(curdir, 'static', '404.html')
    return static.serve_file(path, content_type='text/html') 
开发者ID:cherrypy,项目名称:cherrypy,代码行数:5,代码来源:test_static.py

示例4: show_img

# 需要导入模块: from cherrypy.lib import static [as 别名]
# 或者: from cherrypy.lib.static import serve_file [as 别名]
def show_img(self, name, mimetype):
		fp = path.join(self.datapath, name)
		if(path.exists(fp)):
			return serve_file(fp, mimetype, name)
		else:
			tmpl = self.lookup.get_template("404.mako")
			cherrypy.response.status = 404
			return tmpl.render(page_title="File not found!") 
开发者ID:SecPi,项目名称:SecPi,代码行数:10,代码来源:alarmdata.py

示例5: download

# 需要导入模块: from cherrypy.lib import static [as 别名]
# 或者: from cherrypy.lib.static import serve_file [as 别名]
def download(self, name):
		fp = path.join(self.datapath, name)
		if(path.exists(fp)):
			return serve_file(fp, "application/x-download", "attachment")
		else:
			tmpl = self.lookup.get_template("404.mako")
			cherrypy.response.status = 404
			return tmpl.render(page_title="File not found!") 
开发者ID:SecPi,项目名称:SecPi,代码行数:10,代码来源:alarmdata.py

示例6: rss

# 需要导入模块: from cherrypy.lib import static [as 别名]
# 或者: from cherrypy.lib.static import serve_file [as 别名]
def rss(self):
        # Return static file with ATOM feed
        return serve_file("/bots/telegram-feedgen-bot/static/atom.xml") 
开发者ID:MasterGroosha,项目名称:telegram-rss-generation,代码行数:5,代码来源:sample_custom_post.py

示例7: GET

# 需要导入模块: from cherrypy.lib import static [as 别名]
# 或者: from cherrypy.lib.static import serve_file [as 别名]
def GET(self, id=None):
        """Write our image to a temp file, then give it back to the user"""
        cv2.imwrite(self.image_file, self.image_callback())
        return serve_file(self.image_file, content_type='image/jpeg') 
开发者ID:patrickpoirier51,项目名称:OpenTracker,代码行数:6,代码来源:web_server.py

示例8: download

# 需要导入模块: from cherrypy.lib import static [as 别名]
# 或者: from cherrypy.lib.static import serve_file [as 别名]
def download(self):
        path = os.path.join(absDir, "pdf_file.pdf")
        return static.serve_file(path, "application/x-download",
                                 "attachment", os.path.basename(path)) 
开发者ID:binhex,项目名称:moviegrabber,代码行数:6,代码来源:tut09_files.py


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