Initial test setup

This commit is contained in:
nolan 2025-09-22 21:44:02 -04:00
commit 6ae31fc186
4 changed files with 40 additions and 0 deletions

7
.gitignore vendored Normal file
View File

@ -0,0 +1,7 @@
*.code-workspace
bin/
include/
lib/
lib64
pyvenv.cfg
.vscode/

14
client.py Normal file
View File

@ -0,0 +1,14 @@
from websockets import *
import asyncio, json
async def msg():
uri: str = "ws://127.0.0.1:8765"
async with connect(uri) as websocket:
send: str = input()
await websocket.send(send)
print(f"Client sent {send}")
response: str = await websocket.recv()
print(f"Received: {response}")
if __name__ == "__main__":
asyncio.run(msg())

3
requirements.txt Normal file
View File

@ -0,0 +1,3 @@
MarkupSafe==3.0.2
websockets==15.0.1
Werkzeug==3.1.3

16
server.py Normal file
View File

@ -0,0 +1,16 @@
from websockets import *
import asyncio, json
async def test(websocket: ServerConnection) -> None:
message: str = await websocket.recv()
print(f"Server received: {message}")
response: str = f"Hello {websocket.id}. You sent {message}"
await websocket.send(response)
print(f"Server replied: {response}")
async def main() -> None:
async with serve(test, "", 8765):
await asyncio.Future()
if __name__ == "__main__":
asyncio.run(main())