mirror of
https://github.com/modelscope/FunASR
synced 2025-09-15 14:48:36 +08:00
Create ws_server_demo.py
This commit is contained in:
parent
ea845a0df4
commit
e11618bbb4
@ -0,0 +1,13 @@
|
|||||||
|
# server.py
|
||||||
|
import asyncio
|
||||||
|
import websockets
|
||||||
|
|
||||||
|
async def echo(websocket, path):
|
||||||
|
async for message in websocket:
|
||||||
|
print(message) # 打印收到的消息
|
||||||
|
await websocket.send(message)
|
||||||
|
|
||||||
|
start_server = websockets.serve(echo, "localhost", 7272)
|
||||||
|
|
||||||
|
asyncio.get_event_loop().run_until_complete(start_server)
|
||||||
|
asyncio.get_event_loop().run_forever()
|
||||||
Loading…
Reference in New Issue
Block a user