From 1d1895c32dbb1e852eec7a5523d73958c1435fad Mon Sep 17 00:00:00 2001 From: Tim Van Baak Date: Tue, 15 Jun 2021 20:33:38 -0700 Subject: [PATCH] Fix some issues with running the server --- amanuensis/config.py | 2 +- amanuensis/server/__init__.py | 8 +++++--- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/amanuensis/config.py b/amanuensis/config.py index e159a7f..59d9c37 100644 --- a/amanuensis/config.py +++ b/amanuensis/config.py @@ -9,7 +9,7 @@ class AmanuensisConfig: # If CONFIG_FILE is defined, the config file it points to may override # config values defined on the config object itself. CONFIG_FILE: Optional[str] = None - STATIC_ROOT: Optional[str] = "static" + STATIC_ROOT: Optional[str] = "../resources" SECRET_KEY: Optional[str] = "secret" DATABASE_URI: Optional[str] = "sqlite:///:memory:" TESTING: bool = False diff --git a/amanuensis/server/__init__.py b/amanuensis/server/__init__.py index 9d95b54..0231d89 100644 --- a/amanuensis/server/__init__.py +++ b/amanuensis/server/__init__.py @@ -1,4 +1,5 @@ import json +import os from flask import Flask, g @@ -18,8 +19,8 @@ def get_app( app.config.from_object(config) # If a config file is now specified, also load keys from there - if app.config.get("CONFIG_FILE", None): - app.config.from_file(app.config["CONFIG_FILE"], json.load) + if config_path := app.config.get("CONFIG_FILE", None): + app.config.from_file(os.path.abspath(config_path), json.load) # Assert that all required config values are now set for config_key in ("SECRET_KEY", "DATABASE_URI"): @@ -59,4 +60,5 @@ def get_app( def run(): """Run the server, populating the config from the command line.""" config = CommandLineConfig() - get_app(config).run(debug=config.TESTING) + app = get_app(config) + app.run(debug=app.testing)