Add 404 and server error handlers

This commit is contained in:
Jack O'Sullivan 2019-08-23 13:01:28 +01:00
parent a616342e2e
commit 10005d74d3

View File

@ -1,5 +1,13 @@
from flask import Flask
from flask import Flask, jsonify
app = Flask(__name__)
from . import network, ipam
from . import network, ipam
@app.errorhandler(404)
def err_not_found(e):
return jsonify({'Err': 'API not found'}), 404
@app.errorhandler(Exception)
def err(e):
return jsonify({'Err': f'Error: {e}'}), 500