31 lines
838 B
Python
31 lines
838 B
Python
import json
|
|
import os
|
|
|
|
# Usa o diretório do script para localizar o data/config.json
|
|
BASE_DIR = os.path.dirname(os.path.abspath(__file__))
|
|
CONFIG_FILE = os.path.join(BASE_DIR, "data", "config.json")
|
|
|
|
def get_config():
|
|
if not os.path.exists("/app/data"):
|
|
os.makedirs("/app/data", exist_ok=True)
|
|
|
|
if os.path.exists(CONFIG_FILE):
|
|
try:
|
|
with open(CONFIG_FILE, "r") as f:
|
|
return json.load(f)
|
|
except Exception:
|
|
pass
|
|
|
|
# Configuração Padrão
|
|
return {
|
|
"active_provider": "openrouter",
|
|
"gemini_api_key": "",
|
|
"web_password": "1234"
|
|
}
|
|
|
|
def save_config(cfg):
|
|
if not os.path.exists("/app/data"):
|
|
os.makedirs("/app/data", exist_ok=True)
|
|
with open(CONFIG_FILE, "w") as f:
|
|
json.dump(cfg, f, indent=4)
|