from werkzeug.wrappers import Response
from werkzeug.exceptions import (
HTTPException,
BadRequest, # 400
NotFound, # 404
)
from werkzeug.utils import redirect
import json as _json
def html (tag, **opts) :
"""
Return text/html response for given pvl.web.html
"""
return Response(unicode(tag), mimetype='text/html', **opts)
def json (data, **opts) :
"""
Return text/json response for given object.
"""
return Response(_json.dumps(data), mimetype='text/json', **opts)
def image (file, type='png') :
"""
Return image/{type} response for given file-like object.
"""
# respond with file wrapper
return Response(file, mimetype='image/{type}'.format(type=type), direct_passthrough=True)