def page_not_found(e): """ If this request was for the API, return JSON 404 error. Otherwise render the angular app. """ if request.path.startswith('/api/'): response = {'error': "Page Not Found", 'error_code': HTTP_STATUS.NOT_FOUND} return output_json(response, HTTP_STATUS.NOT_FOUND) return views.index()
def user_unauthorized_callback(): """ If this is a REST API request, return JSON error message (401). Otherwise redirect to the login page. """ if request.path.startswith('/api/'): response = {'error': "Unauthorized", 'error_code': HTTP_STATUS.UNAUTHORIZED} return output_json(response, HTTP_STATUS.UNAUTHORIZED) else: return redirect('login')
def page_not_found(e): """ If this request was for the API, return JSON 404 error. Otherwise render the angular app. """ if request.path.startswith('/api/'): response = { 'error': "Page Not Found", 'error_code': HTTP_STATUS.NOT_FOUND } return output_json(response, HTTP_STATUS.NOT_FOUND) return views.index()
def user_unauthorized_callback(): """ If this is a REST API request, return JSON error message (401). Otherwise redirect to the login page. """ if request.path.startswith('/api/'): response = { 'error': "Unauthorized", 'error_code': HTTP_STATUS.UNAUTHORIZED } return output_json(response, HTTP_STATUS.UNAUTHORIZED) else: return redirect('login')