WebashalarForML commited on
Commit
5c24c28
·
verified ·
1 Parent(s): f67c2f0

Update templates/app_index.html

Browse files
Files changed (1) hide show
  1. 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>Show JSON Response</title>
6
  <style>
7
- body { font-family: sans-serif; padding: 20px; }
8
- button { padding: 8px 12px; }
9
- pre { background: #f0f0f0; padding: 10px; border: 1px solid #ccc; margin-top: 10px; }
 
 
 
 
 
 
 
 
 
 
10
  </style>
11
  </head>
12
  <body>
13
 
14
- <h2>Fetch & Show JSON</h2>
15
- <button id="fetchBtn">Fetch JSON</button>
16
- <pre id="jsonOutput">Click the button to load JSON…</pre>
 
 
 
 
17
 
18
  <script>
19
- document.getElementById('fetchBtn').addEventListener('click', async () => {
20
- const output = document.getElementById('jsonOutput');
21
- output.textContent = 'Loading…';
 
 
 
 
 
 
 
 
 
22
 
23
  try {
24
- const res = await fetch('/process_pdf', { method: 'POST' /*, body: formData if needed */ });
 
 
 
25
  const data = await res.json();
26
- if (!res.ok) {
27
- output.textContent = `Error ${res.status}: ${data.error || JSON.stringify(data)}`;
28
- } else {
29
- // Pretty-print the entire JSON object
30
- output.textContent = JSON.stringify(data, null, 2);
31
- }
32
  } catch (err) {
33
- output.textContent = `Fetch failed: ${err.message}`;
 
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>