fix: absolute path bug

This commit is contained in:
Terry Geng 2020-12-31 11:06:44 +08:00
parent f96c9f7f89
commit 8870667064
No known key found for this signature in database
GPG Key ID: F982F8EA1DF720E7
2 changed files with 6 additions and 3 deletions

View File

@ -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)

View File

@ -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'])