summaryrefslogtreecommitdiffstats
path: root/ogcp
diff options
context:
space:
mode:
authorJavier Sánchez Parra <jsanchez@soleta.eu>2022-09-02 13:44:32 +0200
committerJavier Sánchez Parra <jsanchez@soleta.eu>2022-09-27 09:48:36 +0200
commit07c5cb25d2281d2253729ecc7b7b40efdf6db140 (patch)
treee585cdcadf18579eb50caec144995927538cc927 /ogcp
parent083cb7af7fd35ac2e61192a4f6fe0137a1642ca0 (diff)
Store configuration file path on a global variable
Otherwise, users may change the file path on one place of the code and forget to change the other places.
Diffstat (limited to 'ogcp')
-rw-r--r--ogcp/__init__.py4
-rw-r--r--ogcp/views.py6
2 files changed, 6 insertions, 4 deletions
diff --git a/ogcp/__init__.py b/ogcp/__init__.py
index 5d5f3e4..58de9a4 100644
--- a/ogcp/__init__.py
+++ b/ogcp/__init__.py
@@ -11,8 +11,10 @@ from flask_babel import Babel
from flask import Flask
from os import urandom
+ogcp_cfg_path = 'cfg/ogcp.json'
+
app = Flask(__name__)
-app.config.from_json('cfg/ogcp.json')
+app.config.from_json(ogcp_cfg_path)
app.secret_key = urandom(16)
babel = Babel(app)
diff --git a/ogcp/views.py b/ogcp/views.py
index 16cdfd1..9641ed0 100644
--- a/ogcp/views.py
+++ b/ogcp/views.py
@@ -28,7 +28,7 @@ from ogcp.forms.auth import LoginForm, UserForm, DeleteUserForm
from ogcp.og_server import servers
from flask_babel import lazy_gettext as _l
from flask_babel import _
-from ogcp import app
+from ogcp import app, ogcp_cfg_path
import requests
import datetime
import hashlib
@@ -1486,7 +1486,7 @@ def save_user(form):
'SCOPES': scopes,
}
- filename = os.path.join(app.root_path, 'cfg', 'ogcp.json')
+ filename = os.path.join(app.root_path, ogcp_cfg_path)
with open(filename, 'r+') as file:
config = json.load(file)
@@ -1504,7 +1504,7 @@ def save_user(form):
def delete_user(username):
user = get_user(username)
- filename = os.path.join(app.root_path, 'cfg', 'ogcp.json')
+ filename = os.path.join(app.root_path, ogcp_cfg_path)
with open(filename, 'r+') as file:
config = json.load(file)