Websocket test
This commit is contained in:
@@ -6,6 +6,12 @@ from lnbits.decorators import check_user_exists, validate_uuids
|
||||
from . import copilot_ext
|
||||
from .crud import get_copilot
|
||||
|
||||
@copilot_ext.websocket('/ws')
|
||||
async def ws():
|
||||
while True:
|
||||
data = await websocket.receive()
|
||||
await websocket.send(f"echo {data}")
|
||||
|
||||
@copilot_ext.route("/")
|
||||
@validate_uuids(["usr"], required=True)
|
||||
@check_user_exists()
|
||||
@@ -25,10 +31,4 @@ async def panel(copilot_id):
|
||||
copilot = await get_copilot(copilot_id) or abort(
|
||||
HTTPStatus.NOT_FOUND, "Copilot link does not exist."
|
||||
)
|
||||
return await render_template("copilot/panel.html", copilot=copilot)
|
||||
|
||||
@copilot_ext.websocket('/ws/<copilot_id>')
|
||||
async def ws():
|
||||
while True:
|
||||
data = await websocket.receive()
|
||||
await websocket.send(f"echo {data}")
|
||||
return await render_template("copilot/panel.html", copilot=copilot)
|
||||
Reference in New Issue
Block a user