Сравнить коммиты

..

Нет общих коммитов. «b6661d3ebdb2c0cc51425d765509e1ad94895797» и «b9f96398e3a41c23ef4ef3a447bd26d4160ded7e» имеют совершенно разные истории.

Просмотреть файл

@ -1,6 +1,8 @@
import asyncio
import os
from fastapi import FastAPI, Body
from fastapi import FastAPI
from fastapi.responses import HTMLResponse
from fastapi.websockets import WebSocket, WebSocketDisconnect
import config
@ -38,6 +40,9 @@ class ConnectionManager:
asyncio.ensure_future(connection.send_json(data))
connection_manager = ConnectionManager()
api = FastAPI(
title=config.Main.app_name,
)
@ -60,42 +65,16 @@ scripts = [
]
scripts_cm = ConnectionManager()
@api.post(
path='/api/scripts',
)
async def _(
script_id: int = Body(
validation_alias='id',
),
name: str = Body(),
time: str = Body(),
message_number: str = Body(
validation_alias='messageNumber',
),
is_enabled: bool = Body(
validation_alias='isEnabled',
),
):
i = script_id - 1
scripts[i]['name'] = name
scripts[i]['time'] = time
scripts[i]['messageNumber'] = message_number
scripts[i]['isEnabled'] = is_enabled
@api.websocket(
path='/ws/scripts',
)
async def _(
websocket: WebSocket,
):
await scripts_cm.connect(websocket)
await connection_manager.connect(websocket)
try:
await scripts_cm.broadcast(scripts)
await connection_manager.broadcast(scripts)
while True:
await websocket.receive_json()
await connection_manager.broadcast(await websocket.receive_json())
except WebSocketDisconnect:
scripts_cm.disconnect(websocket)
connection_manager.disconnect(websocket)