Deepfake Authenticator commited on
Commit ·
c9cd8bf
1
Parent(s): f38836d
feat: Add /clear-cache endpoint to manually clear result cache
Browse files- backend/main.py +18 -0
backend/main.py
CHANGED
|
@@ -144,6 +144,24 @@ async def health():
|
|
| 144 |
}
|
| 145 |
|
| 146 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 147 |
@app.post("/analyze-url")
|
| 148 |
async def analyze_from_url(payload: dict):
|
| 149 |
"""Download a video from a URL and analyze it. Used by the browser extension."""
|
|
|
|
| 144 |
}
|
| 145 |
|
| 146 |
|
| 147 |
+
@app.post("/clear-cache")
|
| 148 |
+
async def clear_cache():
|
| 149 |
+
"""Clear the result cache."""
|
| 150 |
+
try:
|
| 151 |
+
from detector import _result_cache
|
| 152 |
+
cache_size = len(_result_cache)
|
| 153 |
+
_result_cache.clear()
|
| 154 |
+
logger.info(f"Cache cleared: {cache_size} entries removed")
|
| 155 |
+
return {
|
| 156 |
+
"status": "success",
|
| 157 |
+
"message": f"Cleared {cache_size} cached results",
|
| 158 |
+
"entries_removed": cache_size
|
| 159 |
+
}
|
| 160 |
+
except Exception as e:
|
| 161 |
+
logger.error(f"Failed to clear cache: {e}")
|
| 162 |
+
raise HTTPException(status_code=500, detail=f"Failed to clear cache: {str(e)}")
|
| 163 |
+
|
| 164 |
+
|
| 165 |
@app.post("/analyze-url")
|
| 166 |
async def analyze_from_url(payload: dict):
|
| 167 |
"""Download a video from a URL and analyze it. Used by the browser extension."""
|