diff --git a/constants.py b/constants.py index 736d286..47c50b4 100644 --- a/constants.py +++ b/constants.py @@ -1,3 +1,4 @@ +import os import json import variables as var @@ -8,9 +9,10 @@ lang_dict = {} def load_lang(lang): global lang_dict, default_lang_dict - with open("lang/en_US.json", "r") as f: + root_dir = os.path.dirname(__file__) + with open(os.path.join(root_dir, "lang/en_US.json"), "r") as f: default_lang_dict = json.load(f) - with open(f"lang/{lang}.json", "r") as f: + with open(os.path.join(root_dir, f"lang/{lang}.json"), "r") as f: lang_dict = json.load(f) diff --git a/interface.py b/interface.py index 88597e5..d392f03 100644 --- a/interface.py +++ b/interface.py @@ -225,7 +225,8 @@ def get_all_dirs(): @web.route("/", methods=['GET']) @requires_auth def index(): - return open(f"templates/index.{var.language}.html", "r").read() + root_dir = os.path.dirname(__file__) + return open(os.path.join(root_dir, f"templates/index.{var.language}.html"), "r").read() @web.route("/playlist", methods=['GET'])