2023-09-26 20:54:40 +00:00
|
|
|
from datetime import datetime
|
|
|
|
from flask.views import MethodView
|
|
|
|
|
|
|
|
from app import Application
|
2023-10-02 13:29:19 +00:00
|
|
|
from models.interface import HealthGet, HealthStatus
|
2023-09-26 20:54:40 +00:00
|
|
|
from . import routes as blp
|
|
|
|
|
|
|
|
instance = 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(instance.alive_since, "%d.%m.%Y %H:%M:%S"),
|
|
|
|
"alive_for": str(datetime.now() - instance.alive_since),
|
|
|
|
"status": HealthStatus.OK
|
|
|
|
}
|
|
|
|
return response
|