#!/usr/bin/python
# -*- coding: UTF-8 -*-

from flask import Blueprint
from flask import jsonify, session, redirect, url_for

import config

from version import __version__, __branch__, __commit__, __commiturl__, __treeurl__

import utils
from utils.decorator import login_required
from utils.template import my_render_template

adm_view = Blueprint( "adm", __name__ )

@adm_view.route( "/ping" )
def ping():
    """
        Ping function to check if the web application is healthy.
    """
    return "pong"

@adm_view.route( "/version" )
def version():
    """
        Function to report the version of the web app.
        The version.py file is re-generated by the CI/CD for production.
    """
    try:
        return jsonify( {
            "error": False,
            "version": __version__,
            "branch": __branch__,
            "commit": __commit__,
            "commiturl": __commiturl__,
            "treeurl": __treeurl__
        } )

    except:
        return jsonify( {
            "error": True
        } )
