diff options
Diffstat (limited to 'day4/task3/server.py')
| -rw-r--r-- | day4/task3/server.py | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/day4/task3/server.py b/day4/task3/server.py index b3cb619..f4e5ebe 100644 --- a/day4/task3/server.py +++ b/day4/task3/server.py @@ -3,6 +3,7 @@ import struct from db import search_by_date import re import json +import time def pack_data(data): @@ -14,7 +15,11 @@ def handle_request(data): match = re.match(r'(\d+):?(\d+)?:?(\d+)?-(.*)', data) if match: *date, msg = match.groups() - return pack_data(json.dumps(search_by_date(*date, msg))) + + t = time.time() + found = search_by_date(*map(lambda i: int(i) if i is not None else i, date), msg) + print(f'Search took {time.time() - t} seconds') + return pack_data(json.dumps(found)) else: print('String not matched.') @@ -63,7 +68,7 @@ def handle_connection(connection, address): connection.sendall(response) -HOST, PORT = ADDR = '0.0.0.0', 6001 +HOST, PORT = ADDR = '0.0.0.0', 6000 sock = socket.socket() sock.bind(ADDR) sock.listen(5) |