support-organizer/backend/fgo-request-manager/routes/health.py

21 lines
683 B
Python
Raw Normal View History

2023-09-26 20:54:40 +00:00
from datetime import datetime
from flask.views import MethodView
2023-11-24 19:50:18 +00:00
from ..app import Application
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