[Instagram Reels] Phase 2 완성 - instagram_bot.py: publish_reels() 추가 (MP4 → Reels API) - upload_video_container(), wait_for_video_ready() 구현 - 로컬 경로 → 공개 URL 자동 변환 (image_host.get_public_video_url()) - scheduler.py: job_distribute_instagram_reels() 추가 (10:30) - image_host.py: get_public_video_url() + 로컬 비디오 서버 추가 - VIDEO_HOST_BASE_URL 환경변수 지원 (Tailscale/CDN) [writer_bot.py] 신규 — 독립 실행형 글쓰기 봇 - api_content.py manual-write 엔드포인트에서 subprocess 호출 가능 - run_pending(): 오늘 날짜 미처리 글감 자동 처리 - run_from_topic(): 직접 주제 지정 - run_from_file(): JSON 파일 지정 - CLI: python bots/writer_bot.py [--topic "..." | --file path.json | --limit N] [보조 시스템 신규] v3.1 CLI + Assist 모드 - blog.cmd: venv Python 경유 Windows 런처 - blog_runtime.py + runtime_guard.py: 실행 진입점 + venv 검증 - blog_engine_cli.py: 대시보드 API 기반 CLI (blog status, blog review 등) - bots/assist_bot.py: URL 기반 수동 어시스트 파이프라인 - dashboard/backend/api_assist.py + frontend/Assist.jsx: 수동모드 탭 [engine_loader.py] v3.1 개선 - OpenClawWriter: --json 플래그 + payloads 파싱 + plain text 폴백 - ClaudeWebWriter: Playwright 쿠키 세션 (Cloudflare 차단으로 현재 비활성) - GeminiWebWriter: gemini-webapi 비공식 클라이언트 [scheduler.py] v3.1 개선 - _call_openclaw(): 플레이스홀더 → EngineLoader 실제 호출 - _build_openclaw_prompt(): 구조화된 HTML 원고 프롬프트 - data/originals/: 원본 article JSON 저장 경로 추가 [설정/환경] 정비 - .env.example: SEEDANCE/ELEVENLABS/GEMINI/RUNWAY 복원 + VIDEO_HOST_BASE_URL, GEMINI_WEB_* , REMOTE_CLAUDE_POLLING_ENABLED 추가 - scripts/setup.bat: data/originals, outputs, assist, novels, config/novels 디렉토리 생성 + 폰트 다운로드 + blog.cmd 기반 Task Scheduler 등록 - requirements.txt: fastapi, uvicorn, python-multipart 추가 Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
88 lines
3.1 KiB
Python
88 lines
3.1 KiB
Python
"""
|
|
dashboard/backend/server.py
|
|
미디어 엔진 컨트롤 패널 — FastAPI 메인 서버
|
|
|
|
실행: uvicorn dashboard.backend.server:app --port 8080
|
|
또는: python -m uvicorn dashboard.backend.server:app --port 8080 --reload
|
|
"""
|
|
import os
|
|
from pathlib import Path
|
|
|
|
from runtime_guard import ensure_project_runtime
|
|
|
|
ensure_project_runtime(
|
|
"dashboard server",
|
|
["fastapi", "uvicorn", "python-dotenv"],
|
|
)
|
|
|
|
from fastapi import FastAPI
|
|
from fastapi.middleware.cors import CORSMiddleware
|
|
from fastapi.staticfiles import StaticFiles
|
|
from fastapi.responses import FileResponse
|
|
|
|
from dashboard.backend import (
|
|
api_overview,
|
|
api_content,
|
|
api_analytics,
|
|
api_novels,
|
|
api_settings,
|
|
api_connections,
|
|
api_tools,
|
|
api_cost,
|
|
api_logs,
|
|
api_assist,
|
|
)
|
|
|
|
app = FastAPI(title="The 4th Path — Control Panel", version="1.0.0")
|
|
|
|
# ── CORS ──────────────────────────────────────────────────────────────────────
|
|
app.add_middleware(
|
|
CORSMiddleware,
|
|
allow_origins=[
|
|
"http://localhost:5173",
|
|
"http://localhost:8080",
|
|
"http://127.0.0.1:5173",
|
|
"http://127.0.0.1:8080",
|
|
],
|
|
allow_credentials=True,
|
|
allow_methods=["*"],
|
|
allow_headers=["*"],
|
|
)
|
|
|
|
# ── API 라우터 등록 ────────────────────────────────────────────────────────────
|
|
app.include_router(api_overview.router, prefix="/api")
|
|
app.include_router(api_content.router, prefix="/api")
|
|
app.include_router(api_analytics.router, prefix="/api")
|
|
app.include_router(api_novels.router, prefix="/api")
|
|
app.include_router(api_settings.router, prefix="/api")
|
|
app.include_router(api_connections.router, prefix="/api")
|
|
app.include_router(api_tools.router, prefix="/api")
|
|
app.include_router(api_cost.router, prefix="/api")
|
|
app.include_router(api_logs.router, prefix="/api")
|
|
app.include_router(api_assist.router, prefix="/api")
|
|
|
|
@app.get("/api/health")
|
|
async def health():
|
|
return {"status": "ok", "service": "The 4th Path Control Panel"}
|
|
|
|
|
|
# ── 정적 파일 서빙 (프론트엔드 빌드 결과) — API 라우터보다 나중에 등록 ──────────
|
|
FRONTEND_DIST = Path(__file__).parent.parent / "frontend" / "dist"
|
|
|
|
if FRONTEND_DIST.exists():
|
|
assets_dir = FRONTEND_DIST / "assets"
|
|
if assets_dir.exists():
|
|
app.mount("/assets", StaticFiles(directory=str(assets_dir)), name="assets")
|
|
|
|
@app.get("/", include_in_schema=False)
|
|
@app.get("/{full_path:path}", include_in_schema=False)
|
|
async def serve_spa(full_path: str = ""):
|
|
# API 경로는 위 라우터가 처리 — 여기는 SPA 라우팅용
|
|
if full_path.startswith("api/"):
|
|
from fastapi.responses import JSONResponse
|
|
return JSONResponse({"detail": "Not Found"}, status_code=404)
|
|
index = FRONTEND_DIST / "index.html"
|
|
if index.exists():
|
|
return FileResponse(str(index))
|
|
return {"status": "frontend not built — run: npm run build"}
|