prthm11 commited on
Commit
4a309b0
·
verified ·
1 Parent(s): 6e17ffe

Upload app_index.html

Browse files
Files changed (1) hide show
  1. templates/app_index.html +125 -0
templates/app_index.html CHANGED
@@ -0,0 +1,125 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <!DOCTYPE html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="UTF-8">
5
+ <title>PDF Image Captioning</title>
6
+ <style>
7
+ body {
8
+ font-family: Arial, sans-serif;
9
+ margin: 30px;
10
+ background-color: #f9f9f9;
11
+ }
12
+
13
+ h2 {
14
+ margin-bottom: 10px;
15
+ }
16
+
17
+ input[type="text"] {
18
+ width: 60%;
19
+ padding: 8px;
20
+ margin-right: 10px;
21
+ }
22
+
23
+ button {
24
+ padding: 8px 16px;
25
+ cursor: pointer;
26
+ }
27
+
28
+ .sprite {
29
+ display: inline-block;
30
+ margin: 20px;
31
+ border: 1px solid #ccc;
32
+ padding: 10px;
33
+ background: white;
34
+ width: 250px;
35
+ vertical-align: top;
36
+ }
37
+
38
+ .sprite img {
39
+ width: 100%;
40
+ height: auto;
41
+ margin-bottom: 10px;
42
+ }
43
+
44
+ .sprite h4, .sprite p {
45
+ margin: 4px 0;
46
+ }
47
+
48
+ #result-container {
49
+ margin-top: 30px;
50
+ }
51
+
52
+ #status {
53
+ margin-top: 20px;
54
+ font-weight: bold;
55
+ }
56
+ </style>
57
+ </head>
58
+ <body>
59
+ <h2>PDF Sprite Image Captioning</h2>
60
+
61
+ <input type="text" id="pdfPath" placeholder="Enter full PDF path (e.g., E:/folder/sample.pdf)">
62
+ <button onclick="processPDF()">Process PDF</button>
63
+
64
+ <div id="status"></div>
65
+ <div id="result-container"></div>
66
+
67
+ <script>
68
+ async function processPDF() {
69
+ const pdfPath = document.getElementById("pdfPath").value.trim();
70
+ const statusEl = document.getElementById("status");
71
+ const resultContainer = document.getElementById("result-container");
72
+
73
+ if (!pdfPath) {
74
+ alert("Please enter a valid PDF path.");
75
+ return;
76
+ }
77
+
78
+ statusEl.textContent = "Processing PDF...";
79
+ resultContainer.innerHTML = "";
80
+
81
+ try {
82
+ const response = await fetch("/process_pdf", {
83
+ method: "POST",
84
+ headers: {
85
+ "Content-Type": "application/json"
86
+ },
87
+ body: JSON.stringify({ pdf_path: pdfPath })
88
+ });
89
+
90
+ const result = await response.json();
91
+
92
+ if (!response.ok) {
93
+ throw new Error(result.error || "Unknown error");
94
+ }
95
+
96
+ statusEl.textContent = result.message;
97
+
98
+ const sprites = result.sprites;
99
+ for (const [key, sprite] of Object.entries(sprites)) {
100
+ const div = document.createElement("div");
101
+ div.className = "sprite";
102
+
103
+ const img = document.createElement("img");
104
+ img.src = `data:image/png;base64,${sprite.base64}`;
105
+
106
+ const name = document.createElement("h4");
107
+ name.textContent = sprite.name || "No name";
108
+
109
+ const desc = document.createElement("p");
110
+ desc.textContent = sprite.description || "No description";
111
+
112
+ div.appendChild(img);
113
+ div.appendChild(name);
114
+ div.appendChild(desc);
115
+
116
+ resultContainer.appendChild(div);
117
+ }
118
+
119
+ } catch (err) {
120
+ statusEl.textContent = "❌ Error: " + err.message;
121
+ }
122
+ }
123
+ </script>
124
+ </body>
125
+ </html>