AutoMaintainer / backend /test_ws.py
purvansh01's picture
Deploy to HuggingFace (with Recent Activity Telemetry)
ae84c0a
Raw
History Blame Contribute Delete
541 Bytes
import asyncio
import websockets
async def test_terminal():
try:
async with websockets.connect("ws://127.0.0.1:8000/api/terminal/ws") as ws:
print("Connected to PTY!")
# Send 'dir' and enter
await ws.send("dir\r")
# Read a few responses
for _ in range(5):
msg = await asyncio.wait_for(ws.recv(), timeout=2.0)
print(f"Received: {repr(msg)}")
except Exception as e:
print(f"Test failed: {e}")
asyncio.run(test_terminal())