Refactor configuration loading to use absolute paths for file access and database path

This commit is contained in:
sevi-py
2025-06-22 18:21:49 +02:00
parent f6f9d4bb63
commit 61728ccb2e

View File

@@ -9,10 +9,18 @@ from cryptography.hazmat.primitives.ciphers import Cipher, algorithms, modes
from cryptography.hazmat.primitives import padding
from cryptography.hazmat.backends import default_backend
# --- Determine absolute path for file access ---
APP_DIR = os.path.dirname(os.path.abspath(__file__))
CONFIG_PATH = os.path.join(APP_DIR, 'config.json')
# Load configuration
with open('config.json') as f:
with open(CONFIG_PATH) as f:
config = json.load(f)
# --- Make database path absolute ---
if not os.path.isabs(config['database']['path']):
config['database']['path'] = os.path.join(APP_DIR, config['database']['path'])
app = Flask(__name__, static_folder='dist', static_url_path='/static')
# Validate and load salts