當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。