From b66f30031604a722196fedaa6ea9f0f1b3ab5226 Mon Sep 17 00:00:00 2001 From: Simon Mendelsohn Date: Thu, 30 Nov 2023 14:04:47 -0500 Subject: [PATCH 1/2] add status and version endpoints --- src/__init__.py | 3 ++- src/status.py | 15 +++++++++++++++ src/utils/constants.py | 2 ++ 3 files changed, 19 insertions(+), 1 deletion(-) create mode 100644 src/status.py diff --git a/src/__init__.py b/src/__init__.py index 8bad26f2..1b59ed38 100644 --- a/src/__init__.py +++ b/src/__init__.py @@ -6,7 +6,7 @@ from quart_cors import cors from google.cloud import firestore -from src import cli, signaling +from src import cli, signaling, status from src.utils import custom_logging from src.web import web, participants, study @@ -23,6 +23,7 @@ def create_app() -> Quart: SECRET_KEY=secrets.token_hex(16), DATABASE=firestore.AsyncClient() ) + app.register_blueprint(status.bp) app.register_blueprint(cli.bp) app.register_blueprint(web.bp) app.register_blueprint(participants.bp) diff --git a/src/status.py b/src/status.py new file mode 100644 index 00000000..71cd5557 --- /dev/null +++ b/src/status.py @@ -0,0 +1,15 @@ +from typing import Tuple +from quart import Blueprint + +from src.utils import constants + + +bp = Blueprint("status", __name__, url_prefix="") + +@bp.route("/status", methods=["GET"]) +async def status() -> Tuple[dict, int]: + return {}, 200 + +@bp.route("/version", methods=["GET"]) +async def version() -> Tuple[dict, int]: + return {"version": constants.BUILD_VERSION}, 200 \ No newline at end of file diff --git a/src/utils/constants.py b/src/utils/constants.py index 40b35b4d..18ff257b 100644 --- a/src/utils/constants.py +++ b/src/utils/constants.py @@ -1,5 +1,7 @@ from copy import deepcopy +import os +BUILD_VERSION = os.getenv('BUILD_VERSION', '') SERVER_GCP_PROJECT = "broad-cho-priv1" SERVER_REGION = "us-central1" SERVER_ZONE = f"{SERVER_REGION}-a" From e2360167888cf7a30e6ca579bbfbe590ed5a412e Mon Sep 17 00:00:00 2001 From: Simon Mendelsohn Date: Thu, 30 Nov 2023 14:37:57 -0500 Subject: [PATCH 2/2] separate appVersion and buildVersion --- src/status.py | 2 +- src/utils/constants.py | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/src/status.py b/src/status.py index 71cd5557..de0f60c9 100644 --- a/src/status.py +++ b/src/status.py @@ -12,4 +12,4 @@ async def status() -> Tuple[dict, int]: @bp.route("/version", methods=["GET"]) async def version() -> Tuple[dict, int]: - return {"version": constants.BUILD_VERSION}, 200 \ No newline at end of file + return {"appVersion": constants.APP_VERSION, "buildVersion": constants.BUILD_VERSION}, 200 \ No newline at end of file diff --git a/src/utils/constants.py b/src/utils/constants.py index 18ff257b..878ad552 100644 --- a/src/utils/constants.py +++ b/src/utils/constants.py @@ -1,6 +1,7 @@ from copy import deepcopy import os +APP_VERSION = os.getenv('APP_VERSION', '') BUILD_VERSION = os.getenv('BUILD_VERSION', '') SERVER_GCP_PROJECT = "broad-cho-priv1" SERVER_REGION = "us-central1"