feat: webscoket

This commit is contained in:
zy7y
2022-09-17 01:11:21 +08:00
parent 29c6e368ae
commit 8da0127729
5 changed files with 33 additions and 0 deletions

14
backend/controller/ws.py Normal file
View File

@@ -0,0 +1,14 @@
from fastapi import FastAPI
from fastapi.websockets import WebSocket
from core.utils import get_system_info
# websocket app
ws_app = FastAPI()
@ws_app.websocket("/ws")
async def ws_func(ws: WebSocket):
await ws.accept()
while True:
await ws.send_json(get_system_info())