22 lines
440 B
Python
Executable file
22 lines
440 B
Python
Executable file
#!/usr/bin/env python
|
|
|
|
import asyncio
|
|
|
|
from websockets.asyncio.server import serve
|
|
|
|
async def server(websocket):
|
|
msg = await websocket.recv()
|
|
print(f"IN : {msg}")
|
|
|
|
answer = f"echoing {msg}"
|
|
|
|
await websocket.send(answer)
|
|
print(f"OUT: {answer}")
|
|
|
|
async def main():
|
|
async with serve(server, "0.0.0.0", 1080):
|
|
await asyncio.get_running_loop().create_future()
|
|
|
|
if __name__ == "__main__":
|
|
asyncio.run(main())
|
|
|