aboutsummaryrefslogtreecommitdiff
path: root/api/status.py
blob: e8ecdf72198f0bdf22f0b2b50ff6b6c7398aa31d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
from flask import Blueprint
from db import cursor
import json

HEAD = open("../.git/HEAD", "r").read().split(" ")[1].strip()
commit = open("../.git/" + HEAD, "r").read().strip()

version = {
    "number": json.loads(open("../package.json", "r").read())["version"],
    "commit": commit,
    "commit_short": commit[0:8]
}

status = Blueprint('server_status', __name__)


@status.route('/status')
def index():
    return {
        # "users": int,
        "games":
        len(
            cursor.execute(
                "select game_id from games where status = \"in_progress\""
            ).fetchall()
        ),
        "version":
        version
    }


dynamic_route = ["/", status]