parent
7fbadce558
commit
5edc3beb78
@ -0,0 +1 @@ |
||||
from . import secondary_functions |
@ -0,0 +1,20 @@ |
||||
import time |
||||
import asyncio |
||||
from aiohttp.web_ws import WebSocketResponse |
||||
|
||||
|
||||
async def time_response(ws: WebSocketResponse, delay: int = 60): |
||||
while True: |
||||
new_time: time.gmtime = time.gmtime(time.time()) |
||||
hour = new_time.tm_hour + 3 |
||||
if hour >= 24: |
||||
hour = hour - 24 |
||||
minutes = new_time.tm_min |
||||
if minutes < 10: |
||||
minutes = f'0{minutes}' |
||||
result_response = f'Время: {hour}:{minutes}' |
||||
try: |
||||
await ws.send_str(result_response) |
||||
await asyncio.sleep(delay) |
||||
except ConnectionResetError: |
||||
await asyncio.sleep(delay) |
Loading…
Reference in new issue