add websocket server

This commit is contained in:
2021-05-16 10:19:54 -04:00
parent d952656dc1
commit 6624cc9e23
4 changed files with 89 additions and 5 deletions
+20
View File
@@ -0,0 +1,20 @@
import asyncio
import websockets
async def hello():
uri = "ws://localhost:50005/messages"
async with websockets.connect(uri) as websocket:
name = "Andreas"
await websocket.send(name)
print(f"> {name}")
while True:
greeting = await websocket.recv()
print(f"< {greeting}")
if greeting == "bye":
break
print('out of here')
asyncio.get_event_loop().run_until_complete(hello())