__init__.py 485 B

1234567891011121314151617181920212223
  1. import logging
  2. from flask import Flask, jsonify
  3. class NetDhcpError(Exception):
  4. def __init__(self, status, *args):
  5. Exception.__init__(self, *args)
  6. self.status = status
  7. app = Flask(__name__)
  8. from . import network
  9. logger = logging.getLogger('gunicorn.error')
  10. @app.errorhandler(404)
  11. def err_not_found(_e):
  12. return jsonify({'Err': 'API not found'}), 404
  13. @app.errorhandler(Exception)
  14. def err(e):
  15. logger.exception(e)
  16. return jsonify({'Err': str(e)}), 500