Deepfake Authenticator commited on
Commit ·
91da8ab
1
Parent(s): 112ba45
fix: timeline cache bust + no-cache headers + debug logging
Browse files- backend/main.py +14 -6
- frontend/index.html +1 -1
- frontend/script.js +2 -0
backend/main.py
CHANGED
|
@@ -138,14 +138,22 @@ async def analyze_video(file: UploadFile = File(...)):
|
|
| 138 |
frontend_path = Path(__file__).parent.parent / "frontend-vanilla"
|
| 139 |
|
| 140 |
if frontend_path.exists():
|
| 141 |
-
@app.get("/")
|
| 142 |
-
async def serve_index():
|
| 143 |
-
return FileResponse(str(frontend_path / "index.html"))
|
| 144 |
-
|
| 145 |
@app.get("/script.js")
|
| 146 |
async def serve_script():
|
| 147 |
-
|
| 148 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 149 |
|
| 150 |
|
| 151 |
if __name__ == "__main__":
|
|
|
|
| 138 |
frontend_path = Path(__file__).parent.parent / "frontend-vanilla"
|
| 139 |
|
| 140 |
if frontend_path.exists():
|
|
|
|
|
|
|
|
|
|
|
|
|
| 141 |
@app.get("/script.js")
|
| 142 |
async def serve_script():
|
| 143 |
+
from fastapi.responses import FileResponse
|
| 144 |
+
return FileResponse(
|
| 145 |
+
str(frontend_path / "script.js"),
|
| 146 |
+
media_type="application/javascript",
|
| 147 |
+
headers={"Cache-Control": "no-store, no-cache, must-revalidate"},
|
| 148 |
+
)
|
| 149 |
+
|
| 150 |
+
@app.get("/")
|
| 151 |
+
async def serve_index():
|
| 152 |
+
from fastapi.responses import FileResponse
|
| 153 |
+
return FileResponse(
|
| 154 |
+
str(frontend_path / "index.html"),
|
| 155 |
+
headers={"Cache-Control": "no-store, no-cache, must-revalidate"},
|
| 156 |
+
)
|
| 157 |
|
| 158 |
|
| 159 |
if __name__ == "__main__":
|
frontend/index.html
CHANGED
|
@@ -408,6 +408,6 @@ header{position:sticky;top:0;z-index:50;background:rgba(5,5,8,0.85);backdrop-fil
|
|
| 408 |
draw();
|
| 409 |
})();
|
| 410 |
</script>
|
| 411 |
-
<script src="script.js"></script>
|
| 412 |
</body>
|
| 413 |
</html>
|
|
|
|
| 408 |
draw();
|
| 409 |
})();
|
| 410 |
</script>
|
| 411 |
+
<script src="script.js?v=3"></script>
|
| 412 |
</body>
|
| 413 |
</html>
|
frontend/script.js
CHANGED
|
@@ -102,6 +102,7 @@ async function analyzeVideo() {
|
|
| 102 |
throw new Error(e.detail || `Server error ${res.status}`);
|
| 103 |
}
|
| 104 |
const data = await res.json();
|
|
|
|
| 105 |
renderResult(data);
|
| 106 |
} catch (err) {
|
| 107 |
showError(err.message || 'Connection to analysis engine failed.');
|
|
@@ -271,6 +272,7 @@ function renderTimeline(data, isFake) {
|
|
| 271 |
|
| 272 |
// Backend sends frame_timeline: [{frame, fake_pct}, ...]
|
| 273 |
const frames = data.frame_timeline || data.frame_scores || [];
|
|
|
|
| 274 |
if (!frames.length) {
|
| 275 |
chart.innerHTML = '<span style="font-size:11px;color:var(--muted);font-family:\'JetBrains Mono\',monospace;margin:auto;">No per-frame data available</span>';
|
| 276 |
return;
|
|
|
|
| 102 |
throw new Error(e.detail || `Server error ${res.status}`);
|
| 103 |
}
|
| 104 |
const data = await res.json();
|
| 105 |
+
console.log('[API Response] keys:', Object.keys(data), '| frame_timeline length:', data.frame_timeline?.length);
|
| 106 |
renderResult(data);
|
| 107 |
} catch (err) {
|
| 108 |
showError(err.message || 'Connection to analysis engine failed.');
|
|
|
|
| 272 |
|
| 273 |
// Backend sends frame_timeline: [{frame, fake_pct}, ...]
|
| 274 |
const frames = data.frame_timeline || data.frame_scores || [];
|
| 275 |
+
console.log('[Timeline] frame_timeline:', data.frame_timeline?.length, 'frames:', frames.length, 'sample:', frames[0]);
|
| 276 |
if (!frames.length) {
|
| 277 |
chart.innerHTML = '<span style="font-size:11px;color:var(--muted);font-family:\'JetBrains Mono\',monospace;margin:auto;">No per-frame data available</span>';
|
| 278 |
return;
|