From 3b7f288c424bc12caf431fe2ab336bff2de86af9 Mon Sep 17 00:00:00 2001 From: Andrew Date: Sat, 25 May 2019 19:43:37 +0400 Subject: =?UTF-8?q?=D0=9E=D0=B1=D0=BD=D0=BE=D0=B2=D0=BB=D0=B5=D0=BD=20READ?= =?UTF-8?q?ME.md?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- day7/main.py | 55 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) create mode 100644 day7/main.py (limited to 'day7/main.py') diff --git a/day7/main.py b/day7/main.py new file mode 100644 index 0000000..7365d05 --- /dev/null +++ b/day7/main.py @@ -0,0 +1,55 @@ +import argparse +import shelve +from config import CONFIG_DB_PATH +from sys import argv + +parser = argparse.ArgumentParser() + +parser.add_argument( + '--chunk-size', type=int, default=1024, + help='Size of chunk that server uses when fetching data from connection' +) + +parser.add_argument( + '--bg-color', type=str, default='white', + help='Default background color of all webpages' +) + +parser.add_argument('--short-log', action='store_true') +parser.add_argument('--show-errors', action='store_true') + +parser.add_argument( + '--log', default='logs/log.log', + help='File where log will be written' +) +parser.add_argument( + '--cookies-db', default='db/cookies.db', + help='Path to file where cookies will be stored' +) + +parser.add_argument( + '--host', default='0.0.0.0', + help='IP of interface where server will be started' +) +parser.add_argument( + '--port', type=int, default=8888, + help='Port on which server will be started' +) + + +args = parser.parse_known_args(argv[1:])[0] + +with (shelve.open(CONFIG_DB_PATH), shelve.open(args.cookies_db)) as (config, cookies): + config['chunk'] = args.chunk_size + config['short_log'] = args.short_log + config['log_path'] = args.log + config['show_errors'] = args.show_errors + config['cookies_db_path'] = args.cookies_db + config['host'] = args.host + config['port'] = args.port + + cookies['bg_color'] = args.bg_color + + +import http_handler +http_handler.main() -- cgit v1.2.3