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


Python Response.headers['Content-Disposition']方法代码示例

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


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

示例1: create_blobinfo_response

# 需要导入模块: from werkzeug import Response [as 别名]
# 或者: from werkzeug.Response import headers['Content-Disposition'] [as 别名]
def create_blobinfo_response(blobinfo, filename=None, mimetype='application/octet-stream'):
    if not mimetype:
        mimetype = blobinfo.content_type
    if not filename:
        filename = blobinfo.filename
    rsp = Response(None, 200)
    rsp.headers[blobstore.BLOB_KEY_HEADER] = blobinfo.key()
    rsp.headers['Content-Type'] = mimetype
    rsp.headers['Content-Disposition'] = 'attachment;filename=%s' % filename
    return rsp
开发者ID:mkrautz,项目名称:mumble-iphoneos-betaweb,代码行数:12,代码来源:util.py

示例2: direct_to_pdf

# 需要导入模块: from werkzeug import Response [as 别名]
# 或者: from werkzeug.Response import headers['Content-Disposition'] [as 别名]
def direct_to_pdf(request, template_name, params=None,
                  pdf_name=None, download=False,
                  font_resolver=font_resolver,
                  image_resolver=image_resolver):
    """Simple generic view to tender rml template.
    """
    params = params or {}
    params['pdf_resource'] = pdf_resource
    pdf_name = pdf_name or params.pop('pdf_name', None)
    if pdf_name==None:
        tname_body = template_name.rpartition('/')[-1].rpartition('.')[0]
        if tname_body:
            pdf_name = tname_body+'.pdf'
        else:
            pdf_name = 'download.pdf'
    params['pdf_name'] = pdf_name
    pdf = render_to_pdf(template_name, params,
                        font_resolver=font_resolver,
                        image_resolver=image_resolver)
    response = Response(pdf, mimetype='application/pdf')
    if download:
        disposition = 'attachment; filename=%s' %(pdf_name)
        response.headers['Content-Disposition'] = disposition
    return response
开发者ID:clsdaniel,项目名称:template2pdf,代码行数:26,代码来源:__init__.py

示例3: application

# 需要导入模块: from werkzeug import Response [as 别名]
# 或者: from werkzeug.Response import headers['Content-Disposition'] [as 别名]
 def application(request):
     response = Response('binary data here', mimetype='application/vnd.ms-excel')
     response.headers['Pragma'] = ', '.join(pragma)
     response.headers['Cache-Control'] = cc.to_header()
     response.headers['Content-Disposition'] = 'attachment; filename=foo.xls'
     return response
开发者ID:AndryulE,项目名称:kitsune,代码行数:8,代码来源:test_fixers.py


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