From a3aaaf2e8897e12506fcaa42c08b9d689592c29b Mon Sep 17 00:00:00 2001 From: Bjarke Madsen <bjarke.madsen@geant.org> Date: Wed, 24 Mar 2021 16:57:33 +0100 Subject: [PATCH] Add version endpoint --- brian_dashboard_manager/__init__.py | 3 ++- brian_dashboard_manager/routes/version.py | 23 +++++++++++++++++++++++ 2 files changed, 25 insertions(+), 1 deletion(-) create mode 100644 brian_dashboard_manager/routes/version.py diff --git a/brian_dashboard_manager/__init__.py b/brian_dashboard_manager/__init__.py index e21a848..7748de4 100644 --- a/brian_dashboard_manager/__init__.py +++ b/brian_dashboard_manager/__init__.py @@ -34,8 +34,9 @@ def create_app(): app.secret_key = os.environ.get('SECRET_KEY', 'super secret session key') app.config[CONFIG_KEY] = app_config - from brian_dashboard_manager.routes import update + from brian_dashboard_manager.routes import update, version app.register_blueprint(update.routes, url_prefix='/update') + app.register_blueprint(version.routes, url_prefix='/version') logging.info('Flask app initialized') environment.setup_logging() diff --git a/brian_dashboard_manager/routes/version.py b/brian_dashboard_manager/routes/version.py new file mode 100644 index 0000000..55d6a88 --- /dev/null +++ b/brian_dashboard_manager/routes/version.py @@ -0,0 +1,23 @@ +import pkg_resources + +from flask import Blueprint, jsonify +from brian_dashboard_manager.routes import common + +routes = Blueprint("version", __name__) +API_VERSION = '0.1' + + +@routes.after_request +def after_request(resp): + return common.after_request(resp) + + +@routes.route("/", methods=['GET', 'POST']) +@common.require_accepts_json +def version(): + version_params = { + 'api': API_VERSION, + 'module': + pkg_resources.get_distribution('brian-dashboard-manager').version + } + return jsonify(version_params) -- GitLab