From 152011d11e032a7297de855724d74da83fa6f1cb Mon Sep 17 00:00:00 2001 From: lonkaars Date: Sun, 25 Apr 2021 17:01:12 +0200 Subject: added version number from package.json and commit hash to footer --- api/api.ts | 8 ++++++++ api/log.py | 8 ++------ api/main.py | 7 ++++++- api/readme.md | 6 +++++- api/status.py | 10 +++++++++- 5 files changed, 30 insertions(+), 9 deletions(-) (limited to 'api') diff --git a/api/api.ts b/api/api.ts index d0dee96..a2a1e95 100644 --- a/api/api.ts +++ b/api/api.ts @@ -62,3 +62,11 @@ export interface gameInfo { started: number; status: 'finished' | 'in_progress' | 'resign' | 'wait_for_opponent'; } + +export interface serverStatus { + games: number; + version: { + commit: string; + number: string; + }; +} diff --git a/api/log.py b/api/log.py index c006f67..b8b7e4a 100644 --- a/api/log.py +++ b/api/log.py @@ -5,12 +5,8 @@ from os import environ load_dotenv() # logging module wrapper (same as db.py) -log_level = [ - None, - logging.ERROR, - logging.WARNING, - logging.INFO - ][int(environ["CONNECT4_LOG_LEVEL"])] +log_level = [None, logging.ERROR, logging.WARNING, + logging.INFO][int(environ["CONNECT4_LOG_LEVEL"])] logging.basicConfig(format="[ %(levelname)s ]: %(message)s", level=log_level) diff --git a/api/main.py b/api/main.py index 58f9ac1..4c043f6 100644 --- a/api/main.py +++ b/api/main.py @@ -10,4 +10,9 @@ load_dotenv() # start the flask/socket.io server if __name__ == "__main__": - io.run(app, host="127.0.0.1", port=5000, debug=bool(int(environ["CONNECT4_DEBUG"]))) + io.run( + app, + host="127.0.0.1", + port=5000, + debug=bool(int(environ["CONNECT4_DEBUG"])) + ) diff --git a/api/readme.md b/api/readme.md index 6d0da60..d904f42 100644 --- a/api/readme.md +++ b/api/readme.md @@ -28,7 +28,11 @@ API return type classes are mostly defined in api/api.ts ```ts { users: int, - games: int + games: int, + version: { + commit: string, + number: string + } } ``` diff --git a/api/status.py b/api/status.py index 32f96ee..a609d42 100644 --- a/api/status.py +++ b/api/status.py @@ -1,5 +1,11 @@ from flask import Blueprint from db import cursor +import json + +version = { + "number": json.loads(open("package.json", "r").read())["version"], + "commit": open(".git/refs/heads/master", "r").read().strip() +} status = Blueprint('server_status', __name__) @@ -13,7 +19,9 @@ def index(): cursor.execute( "select game_id from games where status = \"in_progress\"" ).fetchall() - ) + ), + "version": + version } -- cgit v1.2.3