controller.py 596 Bytes
Newer Older
1
2
3
4
"""The /misc controller provides an API for everything that does not belong
in any of the other categories."""

import logging
5
import re
6
7
8
9
10
11
12
13
14
15
16
from typing import Tuple

from flask import Blueprint, jsonify, Response


misc_blueprint = Blueprint('misc_blueprint', __name__)
logger = logging.getLogger(__name__)


@misc_blueprint.route('/version', methods=['GET'])
def get_version() -> Tuple[Response, int]:
17
18
19
    with open('setup.py') as setup_file:
        text = setup_file.read()
        version = re.search(r'version=\'(\d+\.\d+\.\d+)\',', text).group(1)
20
    return jsonify({'version': version}), 201