Fix: keep connection

This commit is contained in:
DarkCat09 2024-05-03 14:39:29 +04:00
parent 26312a655b
commit 77127d3476
Signed by: DarkCat09
GPG key ID: 0A26CD5B3345D6E3

View file

@ -1,6 +1,5 @@
import asyncio
import json
from typing import Any
import secrets
import time
@ -25,6 +24,7 @@ def generate_key() -> str:
async def handler(socket: websockets.WebSocketServerProtocol) -> None:
async for message in socket:
data = json.loads(await socket.recv())
if 'action' not in data:
await socket.send(response.error_field('action'))
@ -46,7 +46,7 @@ async def handler(socket: websockets.WebSocketServerProtocol) -> None:
if 'url' not in data:
await socket.send(response.error_field('url'))
return
# TODO: pass command to the thread started in `init`
# TODO: start thread and send all yt-dlp's output to client
await socket.send(response.OK)
case _:
await socket.send(response.error_field('action'))