Skip to content
Snippets Groups Projects
Commit cd9604de authored by Simon Künzel's avatar Simon Künzel
Browse files

Update config loading

parent 5ae0408d
No related branches found
No related tags found
No related merge requests found
Pipeline #6805 failed
Pipeline: development

#6806

    #
    # Common py vars
    #
    # With the api version and WITHOUT a trailing /
    # In production with httpS !
    API_BASE_URL = "http://localhost:5000/api/v0"
    # WITHOUT a trailing /
    PERMANENT_MEDIA_DIR = "permanent_media"
    #
    # API specific vars
    #
    # Defaults for development, do not use in production!
    DEBUG = True
    # Name of this instance
    API_SERVER_NAME = "dev"
    # With the api version and WITHOUT a trailing /
    # In production with httpS !
    API_BASE_URL = "http://localhost:5000/api/v0"
    # Prefix which is prepended to paths (which are saved in the database) before they are provided by the api
    # Must include the last /
    FILE_PATH_PREFIX = "https://video.fsmpi.rwth-aachen.de/files/"
    ......
    # noinspection PyUnresolvedReferences
    # We have these here because 'api.config' and 'api.live_config' is nicer than 'app.config' and 'api.live_config.config'
    from app import app, config
    from app import app
    from videoag_common import config
    from api.live_config import config as live_config
    ......@@ -41,12 +41,3 @@ class ApiDatabase(Database):
    database = ApiDatabase(api.config["DATABASE"])
    if api.config["DATABASE"].get("log_all_statements", False):
    def _init_logger():
    import logging
    logger = logging.getLogger('sqlalchemy.engine')
    handler = logging.StreamHandler(sys.stdout)
    logger.addHandler(handler)
    logger.setLevel(logging.INFO)
    _init_logger()
    ......@@ -5,7 +5,7 @@ if __name__ == "__main__":
    import os
    from flask import Flask, Config, Response
    from flask import Flask, Response
    class ApiFlask(Flask):
    ......@@ -18,25 +18,14 @@ class ApiFlask(Flask):
    app = ApiFlask("api")
    config = app.config
    config.from_pyfile(os.path.join(os.getcwd(), os.environ["VIDEOAG_API_CONFIG"]))
    if "VIDEOAG_API_TEST_CONFIG_OVERRIDE" in os.environ:
    override_config = Config(config.root_path)
    override_config.from_pyfile(os.path.join(os.getcwd(), os.environ["VIDEOAG_API_TEST_CONFIG_OVERRIDE"]))
    # Merge the config files manually to also merge dicts (instead of one overwriting the other)
    for key, value in override_config.items():
    if key not in config:
    config[key] = value
    continue
    if isinstance(value, dict) and isinstance(config[key], dict):
    config[key] |= value
    else:
    config[key] = value
    from videoag_common.miscellaneous.util import load_config_file, merge_config_with
    import videoag_common
    merge_config_with(app.config, videoag_common.config, overwrite_non_mergeable=True) # TODO override required?
    # A key is required for flask (This key is used to sign the cookies)
    if "SECRET_KEY" not in config:
    config["SECRET_KEY"] = os.urandom(24) # pragma: no cover
    if "SECRET_KEY" not in app.config:
    app.config["SECRET_KEY"] = os.urandom(24) # pragma: no cover
    # Import routes AFTER initialization
    # noinspection PyUnresolvedReferences
    ......
    Subproject commit 4d05105a1f4664259fe5619d10a71c5712591d39
    Subproject commit 1ffe9749b0cbd3965f85cbd80b201a707bb09965
    0% Loading or .
    You are about to add 0 people to the discussion. Proceed with caution.
    Please register or to comment