support-organizer/backend/fgo_request_manager/routes/health.py

21 lines
668 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
2023-12-21 16:11:47 +00:00
APP = Application.get_instance()
2023-09-26 20:54:40 +00:00
@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 = {
2023-12-21 16:11:47 +00:00
"alive_since": datetime.strftime(APP.alive_since, "%d.%m.%Y %H:%M:%S"),
"alive_for": str(datetime.now() - APP.alive_since),
2023-09-26 20:54:40 +00:00
"status": HealthStatus.OK
}
return response