docker-net-dhcp/net-dhcp/__init__.py
2019-08-23 22:21:43 +01:00

24 lines
485 B
Python

import logging
from flask import Flask, jsonify
class NetDhcpError(Exception):
def __init__(self, status, *args):
Exception.__init__(self, *args)
self.status = status
app = Flask(__name__)
from . import network
logger = logging.getLogger('gunicorn.error')
@app.errorhandler(404)
def err_not_found(_e):
return jsonify({'Err': 'API not found'}), 404
@app.errorhandler(Exception)
def err(e):
logger.exception(e)
return jsonify({'Err': str(e)}), 500