Fix: keep connection
This commit is contained in:
parent
26312a655b
commit
77127d3476
1 changed files with 25 additions and 25 deletions
|
@ -1,6 +1,5 @@
|
||||||
import asyncio
|
import asyncio
|
||||||
import json
|
import json
|
||||||
from typing import Any
|
|
||||||
|
|
||||||
import secrets
|
import secrets
|
||||||
import time
|
import time
|
||||||
|
@ -25,6 +24,7 @@ def generate_key() -> str:
|
||||||
|
|
||||||
|
|
||||||
async def handler(socket: websockets.WebSocketServerProtocol) -> None:
|
async def handler(socket: websockets.WebSocketServerProtocol) -> None:
|
||||||
|
async for message in socket:
|
||||||
data = json.loads(await socket.recv())
|
data = json.loads(await socket.recv())
|
||||||
if 'action' not in data:
|
if 'action' not in data:
|
||||||
await socket.send(response.error_field('action'))
|
await socket.send(response.error_field('action'))
|
||||||
|
@ -46,7 +46,7 @@ async def handler(socket: websockets.WebSocketServerProtocol) -> None:
|
||||||
if 'url' not in data:
|
if 'url' not in data:
|
||||||
await socket.send(response.error_field('url'))
|
await socket.send(response.error_field('url'))
|
||||||
return
|
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)
|
await socket.send(response.OK)
|
||||||
case _:
|
case _:
|
||||||
await socket.send(response.error_field('action'))
|
await socket.send(response.error_field('action'))
|
||||||
|
|
Loading…
Add table
Reference in a new issue