Require that json with higher q than text/html to switch to API
This commit is contained in:
parent
3ec22fca46
commit
c509da2571
1 changed files with 7 additions and 2 deletions
|
|
@ -92,8 +92,13 @@ def split_lines_wrapping(text, width=74, threshold=82):
|
||||||
|
|
||||||
|
|
||||||
def request_wants_json():
|
def request_wants_json():
|
||||||
return request.accept_mimetypes \
|
# we only accept json if the quality of json is greater than the
|
||||||
.best_match(['application/json', 'text/html']) == 'application/json'
|
# quality of text/html because text/html is preferred to support
|
||||||
|
# browsers that accept on */*
|
||||||
|
best = request.accept_mimetypes \
|
||||||
|
.best_match(['application/json', 'text/html'])
|
||||||
|
return best == 'application/json' and \
|
||||||
|
request.accept_mimetypes[best] > request.accept_mimetypes['text/html']
|
||||||
|
|
||||||
|
|
||||||
def requires_login(f):
|
def requires_login(f):
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue