lovespeech/client-test-websocket/entrypoint.py

20 lines
495 B
Python
Executable file

#!/usr/bin/env python
import os
import asyncio
from websockets.asyncio.client import connect
async def test():
uri = "ws://websocket-server:1080"
async with connect(uri) as websocket:
print(f"Get username via:\n name = os.environ.get('USER')")
msg = os.environ.get('USER')
await websocket.send(msg)
print(f"SENT: {msg}")
answer = await websocket.recv()
print(f"RECVEIVED: {answer}")
if __name__ == "__main__":
asyncio.run(test())