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