Spaces:
Sleeping
Sleeping
<html lang="en"> | |
<head> | |
<meta charset="UTF-8"> | |
<title>Show JSON Response</title> | |
<style> | |
body { font-family: sans-serif; padding: 20px; } | |
button { padding: 8px 12px; } | |
pre { background: #f0f0f0; padding: 10px; border: 1px solid #ccc; margin-top: 10px; } | |
</style> | |
</head> | |
<body> | |
<h2>Fetch & Show JSON</h2> | |
<button id="fetchBtn">Fetch JSON</button> | |
<pre id="jsonOutput">Click the button to load JSON…</pre> | |
<script> | |
document.getElementById('fetchBtn').addEventListener('click', async () => { | |
const output = document.getElementById('jsonOutput'); | |
output.textContent = 'Loading…'; | |
try { | |
const res = await fetch('/process_pdf', { method: 'POST' /*, body: formData if needed */ }); | |
const data = await res.json(); | |
if (!res.ok) { | |
output.textContent = `Error ${res.status}: ${data.error || JSON.stringify(data)}`; | |
} else { | |
// Pretty-print the entire JSON object | |
output.textContent = JSON.stringify(data, null, 2); | |
} | |
} catch (err) { | |
output.textContent = `Fetch failed: ${err.message}`; | |
} | |
}); | |
</script> | |
</body> | |
</html> |