- Added jinja2 set statement to fetch settings data from /hermes-web-cli/settings/ API - Updated Form fields to use value/checked properties with proper fallbacks - Implemented settings API endpoint to return current configuration - Removed incorrect load event binding and template variable references
39 lines
1.1 KiB
Plaintext
39 lines
1.1 KiB
Plaintext
import os
|
|
import json
|
|
from pathlib import Path
|
|
|
|
# Load current settings from config file or return defaults
|
|
config_path = Path.home() / ".hermes" / "hermes-web-cli-config.json"
|
|
|
|
default_settings = {
|
|
"security": {
|
|
"require_auth": False,
|
|
"encrypt_storage": False
|
|
},
|
|
"general": {
|
|
"default_model": "",
|
|
"session_timeout": 30,
|
|
"auto_save": True
|
|
},
|
|
"appearance": {
|
|
"theme": "dark"
|
|
}
|
|
}
|
|
|
|
if config_path.exists():
|
|
try:
|
|
with open(config_path, 'r') as f:
|
|
saved_settings = json.load(f)
|
|
# Merge with defaults to ensure all keys exist
|
|
for section, defaults in default_settings.items():
|
|
if section not in saved_settings:
|
|
saved_settings[section] = defaults
|
|
else:
|
|
for key, value in defaults.items():
|
|
if key not in saved_settings[section]:
|
|
saved_settings[section][key] = value
|
|
return saved_settings
|
|
except (json.JSONDecodeError, IOError):
|
|
pass
|
|
|
|
return default_settings |