Skip to content

Commit

Permalink
webcompat#669 Adding a JSON 404 handler
Browse files Browse the repository at this point in the history
Should also be useful for webcompat#667
  • Loading branch information
karlcow committed Aug 14, 2015
1 parent fcb477e commit 37f2eab
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions webcompat/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import urlparse

from babel.dates import format_timedelta
from flask import jsonify
from flask import session
from ua_parser import user_agent_parser

Expand Down Expand Up @@ -298,3 +299,14 @@ def format_link_header(link_header_data):
links = ['<{0}>; rel="{1}"'.format(data['link'], data['rel'])
for data in link_header_data]
return ', '.join(links)


@app.errorhandler(404)
def json_not_found(error=None):
message = {
'status': 404,
'message': 'Not Found',
}
resp = jsonify(message)
resp.status_code = 404
return resp

0 comments on commit 37f2eab

Please sign in to comment.