Download temp_client_test.py from lhc-lab/AI-Colab: direct link, hf CLI and curl.
- Browser
- Download file 444 Bytes
-
https://huggingface.co/datasets/lhc-lab/AI-Colab/resolve/main/temp_client_test.py
- Command line
-
hf download hf://datasets/lhc-lab/AI-Colab/temp_client_test.py
-
curl -L -o temp_client_test.py https://huggingface.co/datasets/lhc-lab/AI-Colab/resolve/main/temp_client_test.py
444 Bytes
| import asyncio | |
| import websockets | |
| import json | |
| async def test_ws_client(): | |
| uri = "ws://127.0.0.1:5005/ws/echo" | |
| try: | |
| async with websockets.connect(uri) as ws: | |
| print('Connected to echo WS') | |
| await ws.send(json.dumps({"test": 1})) | |
| print('Received:', await ws.recv()) | |
| except Exception as e: | |
| print(f'Error during test: {e}') | |
| if __name__ == '__main__': | |
| asyncio.run(test_ws_client()) | |