def _create_app(volume_manager, testing=False):
"""Factory method to create the Flask app and register all dependencies.
Args:
volume_manager (VolumeManager): The volume manager to be used withing the API controller
testing (bool): Whether or not to set the `TESTING` flag on the newly generated Flask application
Returns:
Flask: The application with all the needed dependencies bootstrapped
"""
unhandled_exception_errors = {
'EtcdConnectionFailed': {
'message': "The ETCD cluster is not responding.",
'status': 503,
}
}
config = {
'RESTFUL_JSON': {
'separators': (', ', ': '),
'indent': 2,
'sort_keys': False
},
'TESTING': testing
}
app = Flask(__name__)
app.config.update(**config)
api = RestApi(app, errors=unhandled_exception_errors, catch_all_404s=True)
Api._register_resources(api)
app.volume_manager = volume_manager
app.api = api
return app
评论列表
文章目录