blob: 07eac1a8dbfdf2586c7981717b8af95287b23857 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
|
import asyncio
import logging
from websockets.asyncio.server import serve
addr = "localhost"
port = 3636
logging.basicConfig(level=logging.INFO)
async def handler(websocket):
await websocket.send("Hello")
miw = 0
async for message in websocket:
miw += 1
async for message in websocket:
print(str(websocket))
await websocket.send(message)
async def main():
async with serve(handler, addr, port) as server:
await server.serve_forever()
asyncio.run(main())
|