def request_wants_json():
best = request.accept_mimetypes \
.best_match(["application/json", "text/html"])
return best == "application/json" and \
request.accept_mimetypes[best] >= \
request.accept_mimetypes["text/html"]
文章目录