21 lines
668 B
Python
21 lines
668 B
Python
from datetime import datetime
|
|
from flask.views import MethodView
|
|
|
|
from ..app import Application
|
|
from ..models.interface import HealthGet, HealthStatus
|
|
from . import routes as blp
|
|
|
|
APP = Application.get_instance()
|
|
|
|
@blp.route("/health")
|
|
class ApiVersion(MethodView):
|
|
@blp.doc(summary="Returns the status and alive-time of the server")
|
|
@blp.response(200, HealthGet, description="Successful operation")
|
|
def get(self):
|
|
response = {
|
|
"alive_since": datetime.strftime(APP.alive_since, "%d.%m.%Y %H:%M:%S"),
|
|
"alive_for": str(datetime.now() - APP.alive_since),
|
|
"status": HealthStatus.OK
|
|
}
|
|
return response
|