index.py 文件源码

python
阅读 22 收藏 0 点赞 0 评论 0

项目:tripoli 作者: DDMAL 项目源码 文件源码
def val_with_content_type(value, template):
    """Return either json or text/html with value dict."""
    mimes = request.accept_mimetypes
    json_score = mimes['application/json'] if 'application/json' in mimes else 0
    text_html_score = mimes['text/html'] if 'text/html' in mimes else 0
    if json_score > text_html_score:
        return jsonify(value)
    else:
        return render_template(template, **value)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号