new changes
This commit is contained in:
@@ -1,6 +1,9 @@
|
||||
"""YakPanel - Crontab API"""
|
||||
import json
|
||||
import tempfile
|
||||
import os
|
||||
from pathlib import Path
|
||||
|
||||
from fastapi import APIRouter, Depends, HTTPException
|
||||
from sqlalchemy.ext.asyncio import AsyncSession
|
||||
from sqlalchemy import select
|
||||
@@ -14,6 +17,20 @@ from app.models.crontab import Crontab
|
||||
|
||||
router = APIRouter(prefix="/crontab", tags=["crontab"])
|
||||
|
||||
_CRON_TEMPLATES = Path(__file__).resolve().parent.parent / "data" / "cron_templates.json"
|
||||
|
||||
|
||||
@router.get("/templates")
|
||||
async def crontab_templates(current_user: User = Depends(get_current_user)):
|
||||
"""YakPanel starter cron templates (edit before apply; no external branding)."""
|
||||
if not _CRON_TEMPLATES.is_file():
|
||||
return {"templates": []}
|
||||
try:
|
||||
data = json.loads(_CRON_TEMPLATES.read_text(encoding="utf-8"))
|
||||
return {"templates": data if isinstance(data, list) else []}
|
||||
except (json.JSONDecodeError, OSError):
|
||||
return {"templates": []}
|
||||
|
||||
|
||||
class CreateCrontabRequest(BaseModel):
|
||||
name: str = ""
|
||||
|
||||
Reference in New Issue
Block a user