Checkpoint, configuration can now be done through DB and the site. Server settings are still on the file system
This commit is contained in:
28
config.py
28
config.py
@ -1,32 +1,24 @@
|
||||
import toml
|
||||
import os
|
||||
import secrets
|
||||
|
||||
CONFIG_FILE = 'config.toml'
|
||||
import toml
|
||||
|
||||
CONFIG_FILE = "config.toml"
|
||||
|
||||
|
||||
def load_or_create_config():
|
||||
if not os.path.exists(CONFIG_FILE):
|
||||
admin_password = secrets.token_urlsafe(16)
|
||||
config = {
|
||||
'admin': {
|
||||
'password': admin_password
|
||||
},
|
||||
'directories': {
|
||||
'upload': 'uploads',
|
||||
'thumbnail': 'thumbnails'
|
||||
},
|
||||
'appearance': {
|
||||
'accent_color': '#ff6600'
|
||||
},
|
||||
'server': {
|
||||
'host': '0.0.0.0',
|
||||
'port': 5002
|
||||
}
|
||||
"admin": {"password": admin_password},
|
||||
"directories": {"upload": "uploads", "thumbnail": "thumbnails"},
|
||||
"appearance": {"accent_color": "#ff6600"},
|
||||
"server": {"host": "0.0.0.0", "port": 5002},
|
||||
}
|
||||
with open(CONFIG_FILE, 'w') as f:
|
||||
with open(CONFIG_FILE, "w") as f:
|
||||
toml.dump(config, f)
|
||||
print(f"Generated new config file with admin password: {admin_password}")
|
||||
else:
|
||||
with open(CONFIG_FILE, 'r') as f:
|
||||
with open(CONFIG_FILE, "r") as f:
|
||||
config = toml.load(f)
|
||||
return config
|
||||
|
Reference in New Issue
Block a user