# app.config['RESTX_MASK_HEADER'] = 'fields'
app.config['RESTX_MASK_SWAGGER'] = False
app.config['ERROR_INCLUDE_MESSAGE'] = False
-api = Api(app, version=FLASK_API_VERSION,
- title='INF O2 Services API',
- description='Swagger OpenAPI document for the INF O2 Services',
+api = Api(
+ app, version=FLASK_API_VERSION,
+ catch_all_404s=True,
+ title='INF O2 Services API',
+ description='Swagger OpenAPI document for the INF O2 Services',
)
bus = bootstrap.bootstrap()
MethodNotAllowed,
NotFound,
InternalServerError,
+ HTTPException,
)
def configure_exception(app):
+ @app.errorhandler(HTTPException)
+ def default_error_handler(error):
+ '''Default error handler'''
+ status_code = getattr(error, 'code', 500)
+ problem = ProblemDetails(status_code, str(error))
+ return problem.serialize(), status_code
+
+ @app.errorhandler(NotFound)
+ def handle_notfound(error):
+ '''notfound handler'''
+ problem = ProblemDetails(404, str(error))
+ return problem.serialize(), 404
+
@app.errorhandler(BadRequestException)
def handle_badrequest_exception(error):
'''Return a custom message and 400 status code'''
cp /tests/my-root-ca-cert.pem /configs/my-root-ca-cert.pem
cp /tests/my-server-cert.pem /configs/server.crt
cp /tests/my-server-key.pem /configs/server.key
-gunicorn -b 0.0.0.0:80 o2app.entrypoints.flask_application:app --certfile /configs/server.crt --keyfile /configs/server.key
+gunicorn -b 0.0.0.0:80 o2app.entrypoints.flask_application:app --certfile /configs/server.crt --keyfile /configs/server.key --log-level debug
else
-gunicorn -b 0.0.0.0:80 o2app.entrypoints.flask_application:app
+gunicorn -b 0.0.0.0:80 o2app.entrypoints.flask_application:app --log-level debug
fi