-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathconfig.py
More file actions
33 lines (28 loc) · 1.13 KB
/
config.py
File metadata and controls
33 lines (28 loc) · 1.13 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
import os
import json
from pathlib import Path
class Config:
"""Application configuration settings."""
BASE_DIR = Path(__file__).resolve().parent
@staticmethod
def _load_json_config():
"""Load configuration from config.json file."""
base_dir = Path(__file__).resolve().parent
config_file = os.path.join(base_dir, 'config.json')
try:
with open(config_file, 'r') as f:
return json.load(f)
except FileNotFoundError:
print(f"Warning: {config_file} not found. Using default values.")
return {}
except json.JSONDecodeError:
print(f"Warning: Invalid JSON in {config_file}. Using default values.")
return {}
_json_config = _load_json_config()
SECRET_KEY = 'random_secret_key'
STATIC_FOLDER = 'static'
TEMPLATES_FOLDER = 'templates'
SWI_PROLOG_PATH = _json_config.get('SWI_PROLOG_PATH', 'swipl')
APP_FOLDER = os.path.join(BASE_DIR, 'app')
UPLOAD_FOLDER = os.path.join(APP_FOLDER, 'exports')
GENERATED_CODE_FILE = os.path.join(UPLOAD_FOLDER, 'generated_prolog_code.pl')