File size: 719 Bytes
61898fa | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | from quart import Quart, websocket
import json
import sys
app = Quart(__name__)
@app.websocket('/ws/echo')
async def echo():
print("WS: Connection request...")
await websocket.accept()
print("WS: Connection accepted")
try:
while True:
data = await websocket.receive()
print(f"WS: Received: {data}")
await websocket.send(f"echo: {data}")
except Exception as e:
print(f"WS: Connection closed/error: {e}")
if __name__ == '__main__':
print("Starting Echo Server on port 5005...")
# Принудительно отключаем дебаг для чистоты эксперимента
app.run(host='127.0.0.1', port=5005, debug=False)
|