本文整理汇总了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
示例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
示例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