From 64b1108081b6ee9e89acd104454e7a117e28a061 Mon Sep 17 00:00:00 2001 From: Gareth Coles Date: Sun, 11 Feb 2018 17:09:58 +0000 Subject: Asana integration (#7) * Event dispatching and webhook sending * snekchek --- pysite/base_route.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'pysite/base_route.py') diff --git a/pysite/base_route.py b/pysite/base_route.py index 04694186..a3e8615b 100644 --- a/pysite/base_route.py +++ b/pysite/base_route.py @@ -33,10 +33,18 @@ class APIView(RouteView): "error_message": "Unknown error" } + http_code = 200 + if error_code is ErrorCodes.unknown_route: data["error_message"] = "Unknown API route" - - return jsonify(data) + http_code = 404 + elif error_code is ErrorCodes.unauthorized: + data["error_message"] = "Unauthorized" + http_code = 403 + + response = jsonify(data) + response.status_code = http_code + return response class ErrorView(BaseView): -- cgit v1.2.3