Created
March 23, 2020 15:08
-
-
Save mzaglia/891e042fb635853ca11b12651ce93da6 to your computer and use it in GitHub Desktop.
werkzeug HTTPExceptions as JSON
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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