35 lines
970 B
Python
35 lines
970 B
Python
from fastapi import APIRouter
|
|
from pydantic import BaseModel
|
|
from typing import Optional
|
|
from ..config import settings
|
|
|
|
router = APIRouter()
|
|
|
|
class SettingsUpdate(BaseModel):
|
|
samba_server_ip: str
|
|
samba_username: str
|
|
samba_password: str
|
|
qbittorrent_url: Optional[str]
|
|
qbittorrent_username: Optional[str]
|
|
qbittorrent_password: Optional[str]
|
|
default_comics_path: str
|
|
default_videos_path: str
|
|
stash_enabled: Optional[bool]
|
|
stash_db_path: Optional[str]
|
|
stash_generated_path: Optional[str]
|
|
stash_remote_base: Optional[str]
|
|
stash_container_base: Optional[str]
|
|
stash_share: Optional[str]
|
|
|
|
@router.get("/")
|
|
def get_settings():
|
|
return settings.model_dump()
|
|
|
|
@router.post("/")
|
|
def update_settings(update: SettingsUpdate):
|
|
for key, value in update.model_dump().items():
|
|
if hasattr(settings, key):
|
|
setattr(settings, key, value)
|
|
settings.save_to_json()
|
|
return {"message": "Settings updated"}
|