本文整理匯總了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