summaryrefslogtreecommitdiff
path: root/kvmd/apps/pst
diff options
context:
space:
mode:
authorMaxim Devaev <[email protected]>2024-07-08 03:41:29 +0300
committerMaxim Devaev <[email protected]>2024-12-17 18:20:04 +0200
commit630610bc532299f15ff7ee12d40f617de450aae0 (patch)
treeca0a83f1aa5848a4605034c0394f1edfd0bea7ce /kvmd/apps/pst
parente0bbf6968ef8295274793a564e717f95f42983d7 (diff)
switch
Diffstat (limited to 'kvmd/apps/pst')
-rw-r--r--kvmd/apps/pst/server.py12
1 files changed, 12 insertions, 0 deletions
diff --git a/kvmd/apps/pst/server.py b/kvmd/apps/pst/server.py
index 79bbf7c8..8d8bf9d4 100644
--- a/kvmd/apps/pst/server.py
+++ b/kvmd/apps/pst/server.py
@@ -24,6 +24,7 @@ import os
import asyncio
from aiohttp.web import Request
+from aiohttp.web import Response
from aiohttp.web import WebSocketResponse
from ...logging import get_logger
@@ -35,6 +36,7 @@ from ... import fstab
from ...htserver import exposed_http
from ...htserver import exposed_ws
+from ...htserver import make_json_response
from ...htserver import WsSession
from ...htserver import HttpServer
@@ -65,6 +67,16 @@ class PstServer(HttpServer): # pylint: disable=too-many-arguments,too-many-inst
await ws.send_event("loop", {})
return (await self._ws_loop(ws))
+ @exposed_http("GET", "/state")
+ async def __state_handler(self, _: Request) -> Response:
+ return make_json_response({
+ "clients": len(self._get_wss()),
+ "data": {
+ "path": self.__data_path,
+ "write_allowed": self.__is_write_available(),
+ },
+ })
+
@exposed_ws("ping")
async def __ws_ping_handler(self, ws: WsSession, _: dict) -> None:
await ws.send_event("pong", {})