Scratch_vlm_v1_2 / templates /app_index.html
WebashalarForML's picture
Update templates/app_index.html
5c24c28 verified
<!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>