Initial test setup
This commit is contained in:
commit
6ae31fc186
7
.gitignore
vendored
Normal file
7
.gitignore
vendored
Normal file
@ -0,0 +1,7 @@
|
||||
*.code-workspace
|
||||
bin/
|
||||
include/
|
||||
lib/
|
||||
lib64
|
||||
pyvenv.cfg
|
||||
.vscode/
|
14
client.py
Normal file
14
client.py
Normal 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
3
requirements.txt
Normal file
@ -0,0 +1,3 @@
|
||||
MarkupSafe==3.0.2
|
||||
websockets==15.0.1
|
||||
Werkzeug==3.1.3
|
16
server.py
Normal file
16
server.py
Normal 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())
|
Loading…
x
Reference in New Issue
Block a user