Skip to content

Instantly share code, notes, and snippets.

@Porter97
Created March 30, 2020 19:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Porter97/c27ac633e337036dd0412947d44353f4 to your computer and use it in GitHub Desktop.
Save Porter97/c27ac633e337036dd0412947d44353f4 to your computer and use it in GitHub Desktop.
from flask import jsonify
from . import main
@main.app_errorhandler(403)
def forbidden(e):
response = jsonify({'errors': {'Forbidden:': [e]}})
response.status_code = 403
return response
@main.app_errorhandler(404)
def page_not_found(e):
response = jsonify({'errors': {'Page Not Found': [e]}})
response.status_code = 404
return response
@main.app_errorhandler(500)
def internal_server_error(e):
response = jsonify({'errors': {'Internal Server Error': [e]}})
response.status_code = 500
return response
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment