Files
projects/Dockers/puppeteer-api/app/routes/cache.py
T
Bram de3919a4b5
Build and Push Docker Images / build-and-push (push) Successful in 33s
split up application
2025-05-02 21:15:30 +02:00

24 lines
800 B
Python

from fastapi import APIRouter, HTTPException, Header
from typing import Optional
from app.config import API_KEY
from app.services.cache import clear_cache, get_cache_stats
router = APIRouter()
@router.get("/cache/clear")
async def clear_cache_route(x_api_key: Optional[str] = Header(None)):
"""Clear the entire cache database"""
# Validate API key
if not x_api_key or x_api_key != API_KEY:
raise HTTPException(status_code=401, detail="Invalid API key")
return clear_cache()
@router.get("/cache/stats")
async def cache_stats_route(x_api_key: Optional[str] = Header(None)):
"""Get cache statistics"""
# Validate API key
if not x_api_key or x_api_key != API_KEY:
raise HTTPException(status_code=401, detail="Invalid API key")
return get_cache_stats()