Compare commits

..

No commits in common. '55374189682eb67a49e54e134755448628570a29' and '3dbb0257ae88fa10033e7216e44797664dac98e8' have entirely different histories.

@ -17,5 +17,4 @@ async def time_response(ws: WebSocketResponse, delay: int = 60):
await ws.send_str(result_response)
await asyncio.sleep(delay)
except ConnectionResetError:
break
await asyncio.sleep(delay)

@ -21,12 +21,19 @@ async def websocket_handler(request):
await ws.prepare(request)
asyncio.create_task(secondary_functions.time_response(ws, delay=60))
async for msg in ws:
if msg.type == aiohttp.WSMsgType.TEXT:
if msg.data == 'close':
await ws.close()
else:
await ws.send_str(f'Вы ввели: {msg.data}')
elif msg.type == WSMsgType.ERROR:
print('ws connection closed with exception %s' %
ws.exception())
print('websocket connection closed')
return ws

@ -6,4 +6,4 @@ app = create_app()
if __name__ == '__main__':
aiohttp.web.run_app(app)
# Добавить 2 страничку, подключить ws, отправлял текущие время раз в минуту. Ну и также отвечать на собщения.

Loading…
Cancel
Save