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