uhhh lots of things
All checks were successful
All checks were successful
This commit is contained in:
@ -9,10 +9,19 @@ class Configuration:
|
||||
|
||||
def __init__(self, config_path):
|
||||
self.config_path = config_path
|
||||
|
||||
self.content_dir: Path = None
|
||||
self.templates_dir: Path = None
|
||||
self.styles_dir: Path = None
|
||||
|
||||
self.listen_address: str = "127.0.0.1"
|
||||
self.listen_port: int = 8080
|
||||
self.debug: bool = False
|
||||
self.access_log: bool = True
|
||||
self.max_threads: int = 4
|
||||
self.admin_browser: bool = False
|
||||
self.admin_password: str = None
|
||||
|
||||
def load_config(self):
|
||||
try:
|
||||
with open(self.config_path, "rb") as f:
|
||||
@ -40,6 +49,18 @@ class Configuration:
|
||||
if not self.styles_dir:
|
||||
raise ValueError("Config file does not contain styles_dir path")
|
||||
self.styles_dir = Path(self.styles_dir)
|
||||
|
||||
server = self.config_data.get("server", {})
|
||||
if not server:
|
||||
raise ValueError("Config file does not contain server section")
|
||||
|
||||
self.listen_address = server.get("listen_address", self.listen_address)
|
||||
self.listen_port = server.get("listen_port", self.listen_port)
|
||||
self.debug = server.get("debug", self.debug)
|
||||
self.access_log = server.get("access_log", self.access_log)
|
||||
self.max_threads = server.get("max_threads", self.max_threads)
|
||||
self.admin_browser = server.get("admin_browser", self.admin_browser)
|
||||
self.admin_password = server.get("admin_password", self.admin_password)
|
||||
|
||||
def set_globals(self):
|
||||
global CONTENT_DIR, TEMPLATES_DIR, STYLES_DIR
|
||||
|
Reference in New Issue
Block a user