Phase 2 of the full modernization: - App factory pattern with create_app() - Settings via dataclass with env vars - Dependency injection container - Router stubs for auth, storage, api, recipes, cache, runs - Service layer stubs for run, recipe, cache - Repository layer placeholder Routes are stubs that import from legacy server.py during migration. Next: Migrate each router fully with templates. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
56 lines
1.6 KiB
Python
56 lines
1.6 KiB
Python
"""
|
|
Cache and media routes for L1 server.
|
|
|
|
Handles content retrieval, metadata, media preview, and publishing.
|
|
"""
|
|
|
|
from fastapi import APIRouter, Request, Depends, HTTPException
|
|
from fastapi.responses import HTMLResponse, FileResponse
|
|
|
|
from artdag_common.middleware import UserContext, wants_html
|
|
|
|
from ..dependencies import require_auth, get_templates, get_current_user
|
|
|
|
router = APIRouter()
|
|
|
|
|
|
# TODO: Migrate routes from server.py lines 2767-4200
|
|
# - GET /cache/{content_hash} - Get content details
|
|
# - GET /cache/{content_hash}/raw - Download raw file
|
|
# - GET /cache/{content_hash}/mp4 - Video conversion
|
|
# - GET /cache/{content_hash}/meta - Get metadata
|
|
# - PATCH /cache/{content_hash}/meta - Update metadata
|
|
# - POST /cache/{content_hash}/publish - Publish to L2
|
|
# - PATCH /cache/{content_hash}/republish - Republish
|
|
# - DELETE /cache/{content_hash} - Delete content
|
|
# - POST /cache/import - Import from IPFS
|
|
# - POST /cache/upload - Upload content
|
|
# - GET /media - Media list
|
|
|
|
|
|
@router.get("/cache/{content_hash}")
|
|
async def get_cache_item(
|
|
content_hash: str,
|
|
request: Request,
|
|
):
|
|
"""Get cached content details or serve the file."""
|
|
# TODO: Implement with content negotiation
|
|
raise HTTPException(501, "Not yet migrated")
|
|
|
|
|
|
@router.get("/cache/{content_hash}/raw")
|
|
async def download_raw(content_hash: str):
|
|
"""Download the raw cached file."""
|
|
# TODO: Implement
|
|
raise HTTPException(501, "Not yet migrated")
|
|
|
|
|
|
@router.get("/media")
|
|
async def list_media(
|
|
request: Request,
|
|
user: UserContext = Depends(require_auth),
|
|
):
|
|
"""List all media in cache."""
|
|
# TODO: Implement
|
|
raise HTTPException(501, "Not yet migrated")
|