diff --git a/matemat/webserver/config.py b/matemat/webserver/config.py index c220adc..53386b5 100644 --- a/matemat/webserver/config.py +++ b/matemat/webserver/config.py @@ -1,6 +1,7 @@ from typing import Any, Dict +import os from configparser import ConfigParser @@ -30,14 +31,14 @@ def parse_config_file(path: str) -> Dict[str, Any]: # Replace the original option transformation by a string constructor to preserve the case of config keys parser.optionxform = str # Read the configuration file - parser.read(path, 'utf-8') + parser.read(os.path.expanduser(path), 'utf-8') # Read values from the [Matemat] section, if present, falling back to default values if 'Matemat' in parser.sections(): config['listen'] = parser['Matemat'].get('Address', config['listen']) config['port'] = int(parser['Matemat'].get('Port', config['port'])) - config['staticroot'] = parser['Matemat'].get('StaticPath', config['staticroot']) - config['templateroot'] = parser['Matemat'].get('TemplatePath', config['templateroot']) + config['staticroot'] = parser['Matemat'].get('StaticPath', os.path.expanduser(config['staticroot'])) + config['templateroot'] = parser['Matemat'].get('TemplatePath', os.path.expanduser(config['templateroot'])) # Read all values from the [Pagelets] section, if present. These values are passed to pagelet functions if 'Pagelets' in parser.sections():