Skip to content

Instantly share code, notes, and snippets.

@mzaglia
Created March 23, 2020 15:08
Show Gist options
  • Save mzaglia/891e042fb635853ca11b12651ce93da6 to your computer and use it in GitHub Desktop.
Save mzaglia/891e042fb635853ca11b12651ce93da6 to your computer and use it in GitHub Desktop.
werkzeug HTTPExceptions as JSON
from flask import Flask
from werkzeug.exceptions import HTTPException
app = Flask(__name__)
@app.errorhandler(HTTPException)
def http_exception_handler(e):
return {'code': e.code, 'description': e.description}
if __name__ == '__main__':
app.run(debug=True)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment