diff options
Diffstat (limited to 'day7/main.py')
| -rw-r--r-- | day7/main.py | 55 |
1 files changed, 55 insertions, 0 deletions
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() |