Download app/routers/admin/system.py from binhugg2/api: direct link, hf CLI and curl.
- Browser
- Download file 1.36 kB
-
https://huggingface.co/spaces/binhugg2/api/resolve/main/app/routers/admin/system.py
- Command line
-
hf download hf://spaces/binhugg2/api/app/routers/admin/system.py
-
curl -L -o system.py https://huggingface.co/spaces/binhugg2/api/resolve/main/app/routers/admin/system.py
1.36 kB
| from fastapi import APIRouter, Depends | |
| from sqlalchemy.ext.asyncio import AsyncSession | |
| from app.database import get_db | |
| from app.dependencies import require_permission | |
| from app.config import settings | |
| from app.models.admin import Admin | |
| from app.schemas.admin.system import SystemConfigUpdateRequest | |
| from app.schemas.common import ApiResponse | |
| router = APIRouter() | |
| async def get_config( | |
| admin: Admin = Depends(require_permission("system:config")), | |
| ): | |
| return ApiResponse.ok({ | |
| "sync_cron_hour": settings.SYNC_CRON_HOUR, | |
| "sync_max_concurrent": settings.SYNC_MAX_CONCURRENT, | |
| "access_token_expire_minutes": settings.ACCESS_TOKEN_EXPIRE_MINUTES, | |
| }) | |
| async def update_config( | |
| req: SystemConfigUpdateRequest, | |
| admin: Admin = Depends(require_permission("system:btn:save")), | |
| ): | |
| from app.services.scheduler import start_scheduler, stop_scheduler | |
| if req.sync_cron_hour is not None: | |
| try: | |
| stop_scheduler() | |
| settings.SYNC_CRON_HOUR = req.sync_cron_hour | |
| start_scheduler() | |
| except Exception: | |
| pass | |
| if req.access_token_expire_minutes is not None: | |
| settings.ACCESS_TOKEN_EXPIRE_MINUTES = req.access_token_expire_minutes | |
| return ApiResponse.ok() | |