Spaces:
Sleeping
Sleeping
File size: 1,583 Bytes
f67c2f0 5c24c28 f67c2f0 5c24c28 f67c2f0 5c24c28 f67c2f0 5c24c28 f67c2f0 5c24c28 f67c2f0 5c24c28 f67c2f0 5c24c28 f67c2f0 5c24c28 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 |
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>PDF → JSON Debug View</title>
<style>
body {
font-family: Arial, sans-serif;
padding: 20px;
background: #fafafa;
}
#output {
margin-top: 20px;
padding: 10px;
background: #fff;
border: 1px solid #ddd;
white-space: pre-wrap;
word-wrap: break-word;
}
</style>
</head>
<body>
<h2>Upload PDF and See Raw JSON Response</h2>
<form id="pdfForm">
<input type="file" id="pdfFile" name="pdf_file" accept="application/pdf">
<button type="submit">Upload</button>
</form>
<div id="output">No data yet.</div>
<script>
document.getElementById('pdfForm').addEventListener('submit', async e => {
e.preventDefault();
const fileInput = document.getElementById('pdfFile');
if (!fileInput.files[0]) {
alert('Please choose a PDF.');
return;
}
const formData = new FormData();
formData.append('pdf_file', fileInput.files[0]);
document.getElementById('output').textContent = 'Processing…';
try {
const res = await fetch('/process_pdf', {
method: 'POST',
body: formData
});
const data = await res.json();
// Dump entire JSON (including errors if any)
document.getElementById('output').textContent =
JSON.stringify(data, null, 2);
} catch (err) {
document.getElementById('output').textContent =
`Fetch error:\n${err.message}`;
}
});
</script>
</body>
</html>
|