當前位置: 首頁>>代碼示例>>Python>>正文


Python Response.mimetype方法代碼示例

本文整理匯總了Python中werkzeug.Response.mimetype方法的典型用法代碼示例。如果您正苦於以下問題:Python Response.mimetype方法的具體用法?Python Response.mimetype怎麽用?Python Response.mimetype使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在werkzeug.Response的用法示例。


在下文中一共展示了Response.mimetype方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: static

# 需要導入模塊: from werkzeug import Response [as 別名]
# 或者: from werkzeug.Response import mimetype [as 別名]
 def static(self, request, filename):
     response = Response(open(path.join(web_media_path, filename)).read())
     if filename.endswith('.js'):
         response.mimetype = 'application/javascript'
     elif filename.endswith('.css'):
         response.mimetype = 'text/css'
     return response
開發者ID:mgax,項目名稱:notespace,代碼行數:9,代碼來源:server.py

示例2: session_debug

# 需要導入模塊: from werkzeug import Response [as 別名]
# 或者: from werkzeug.Response import mimetype [as 別名]
def session_debug():
    if local.application.debug == False:
        return notfound()
    from pprint import pformat
    local.session.init()
    response = Response(pformat(local.session.data))
    response.mimetype="text/plain"
    response.charset = "utf-8"
    return response
開發者ID:bjornua,項目名稱:fprojekt2010,代碼行數:11,代碼來源:responders.py

示例3: read_pagefile

# 需要導入模塊: from werkzeug import Response [as 別名]
# 或者: from werkzeug.Response import mimetype [as 別名]
def read_pagefile(url):
    wiki = get_wiki()
    user = current_user.get_id()
    page_url = os.path.dirname(url_from_viewarg(url)).\
        replace('\\', '/').\
        rstrip('/')
    page = get_page_or_raise(wiki, page_url, fields=['path'],
                             check_perms=(user, 'read'))
    # If no exception was thrown, we're good for reading the file.

    path_no_ext, _ = os.path.splitext(page.path)
    file_path = os.path.join(path_no_ext, os.path.basename(url))
    try:
        f = open(file_path, 'rb')
    except OSError:
        abort(404)

    r = Response(wrap_file(request.environ, f), direct_passthrough=True)
    _, ext = os.path.splitext(url)
    r.mimetype = mimetype_map.get(ext, '')
    return r
開發者ID:ludovicchabant,項目名稱:Wikked,代碼行數:23,代碼來源:commonroutes.py

示例4: show_image

# 需要導入模塊: from werkzeug import Response [as 別名]
# 或者: from werkzeug.Response import mimetype [as 別名]
def show_image(id):
    response = Response(user.get_image(id))
    response.mimetype="image/jpeg"
    return response
開發者ID:bjornua,項目名稱:fprojekt2010,代碼行數:6,代碼來源:responders.py


注:本文中的werkzeug.Response.mimetype方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。