Update index.html
Browse files- index.html +162 -171
index.html
CHANGED
@@ -1,171 +1,162 @@
|
|
1 |
-
<!DOCTYPE html>
|
2 |
-
<html lang="en">
|
3 |
-
<head>
|
4 |
-
<meta charset="UTF-8" />
|
5 |
-
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
6 |
-
<title>
|
7 |
-
<style>
|
8 |
-
:root {
|
9 |
-
--primary-color: #4A90E2;
|
10 |
-
--secondary-color: #f4f6f8;
|
11 |
-
--text-color: #333;
|
12 |
-
--btn-color: #4A90E2;
|
13 |
-
--btn-hover: #357ABD;
|
14 |
-
--card-bg: #fff;
|
15 |
-
--card-shadow: rgba(0, 0, 0, 0.1);
|
16 |
-
--border-radius: 8px;
|
17 |
-
--transition: 0.3s;
|
18 |
-
--max-width: 900px;
|
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 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
border:
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
<
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
<
|
113 |
-
|
114 |
-
<
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
-
|
151 |
-
|
152 |
-
|
153 |
-
}
|
154 |
-
|
155 |
-
|
156 |
-
|
157 |
-
|
158 |
-
|
159 |
-
|
160 |
-
|
161 |
-
|
162 |
-
|
163 |
-
document.getElementById('qa-btn').addEventListener('click', () => {
|
164 |
-
const q = document.getElementById('question-input').value.trim();
|
165 |
-
if (!q) { document.getElementById('qa-result').textContent = 'Please enter a question.'; return; }
|
166 |
-
sendData('/api/qa', document.getElementById('file-input-qa'), { question: q }, document.getElementById('qa-result'));
|
167 |
-
});
|
168 |
-
</script>
|
169 |
-
</div>
|
170 |
-
</body>
|
171 |
-
</html>
|
|
|
1 |
+
<!DOCTYPE html>
|
2 |
+
<html lang="en">
|
3 |
+
<head>
|
4 |
+
<meta charset="UTF-8" />
|
5 |
+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
6 |
+
<title>Smart Analyzer</title>
|
7 |
+
<style>
|
8 |
+
:root {
|
9 |
+
--primary-color: #4A90E2;
|
10 |
+
--secondary-color: #f4f6f8;
|
11 |
+
--text-color: #333;
|
12 |
+
--btn-color: #4A90E2;
|
13 |
+
--btn-hover: #357ABD;
|
14 |
+
--card-bg: #fff;
|
15 |
+
--card-shadow: rgba(0, 0, 0, 0.1);
|
16 |
+
--border-radius: 8px;
|
17 |
+
--transition: 0.3s;
|
18 |
+
--max-width: 900px;
|
19 |
+
}
|
20 |
+
* { box-sizing: border-box; }
|
21 |
+
body {
|
22 |
+
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
|
23 |
+
color: var(--text-color);
|
24 |
+
background: var(--secondary-color);
|
25 |
+
margin: 0;
|
26 |
+
padding: 20px;
|
27 |
+
display: flex;
|
28 |
+
justify-content: center;
|
29 |
+
}
|
30 |
+
.container {
|
31 |
+
width: 100%;
|
32 |
+
max-width: var(--max-width);
|
33 |
+
}
|
34 |
+
h1 {
|
35 |
+
text-align: center;
|
36 |
+
color: var(--primary-color);
|
37 |
+
margin-bottom: 40px;
|
38 |
+
}
|
39 |
+
.section {
|
40 |
+
background: var(--card-bg);
|
41 |
+
padding: 20px;
|
42 |
+
margin-bottom: 30px;
|
43 |
+
border-radius: var(--border-radius);
|
44 |
+
box-shadow: 0 2px 8px var(--card-shadow);
|
45 |
+
transition: transform var(--transition);
|
46 |
+
}
|
47 |
+
.section:hover { transform: translateY(-3px); }
|
48 |
+
h2 {
|
49 |
+
margin-top: 0;
|
50 |
+
color: var(--primary-color);
|
51 |
+
border-bottom: 2px solid var(--secondary-color);
|
52 |
+
padding-bottom: 5px;
|
53 |
+
}
|
54 |
+
label {
|
55 |
+
display: block;
|
56 |
+
margin-top: 15px;
|
57 |
+
font-weight: bold;
|
58 |
+
}
|
59 |
+
input[type="file"], input[type="text"], button, textarea {
|
60 |
+
width: 100%;
|
61 |
+
padding: 10px;
|
62 |
+
margin-top: 8px;
|
63 |
+
border: 1px solid #ccc;
|
64 |
+
border-radius: var(--border-radius);
|
65 |
+
font-size: 1rem;
|
66 |
+
}
|
67 |
+
button {
|
68 |
+
background: var(--btn-color);
|
69 |
+
color: #fff;
|
70 |
+
border: none;
|
71 |
+
margin-top: 20px;
|
72 |
+
padding: 12px;
|
73 |
+
font-size: 1rem;
|
74 |
+
border-radius: var(--border-radius);
|
75 |
+
cursor: pointer;
|
76 |
+
transition: background var(--transition);
|
77 |
+
}
|
78 |
+
button:hover { background: var(--btn-hover); }
|
79 |
+
.results {
|
80 |
+
margin-top: 20px;
|
81 |
+
padding: 15px;
|
82 |
+
background: var(--secondary-color);
|
83 |
+
border-radius: var(--border-radius);
|
84 |
+
border: 1px solid #ddd;
|
85 |
+
min-height: 60px;
|
86 |
+
}
|
87 |
+
@media (min-width: 768px) {
|
88 |
+
.grid { display: flex; gap: 20px; }
|
89 |
+
.grid > div { flex: 1; }
|
90 |
+
}
|
91 |
+
</style>
|
92 |
+
</head>
|
93 |
+
<body>
|
94 |
+
<div class="container">
|
95 |
+
<h1>Smart Analyzer</h1>
|
96 |
+
<div class="grid">
|
97 |
+
<div class="section">
|
98 |
+
<h2>Summarize a Document</h2>
|
99 |
+
<input type="file" id="summary-file" accept=".pdf,.docx,.txt">
|
100 |
+
<button id="summarize-btn">Summarize</button>
|
101 |
+
<div id="summary-result" class="results">Your summary will appear here.</div>
|
102 |
+
</div>
|
103 |
+
<div class="section">
|
104 |
+
<h2>Ask a Question</h2>
|
105 |
+
<input type="file" id="qa-file" accept=".pdf,.docx,.txt,image/*">
|
106 |
+
<input type="text" id="qa-question" placeholder="Type your question here...">
|
107 |
+
<button id="qa-btn">Ask</button>
|
108 |
+
<div id="qa-result" class="results">Answer will appear here.</div>
|
109 |
+
</div>
|
110 |
+
<div class="section">
|
111 |
+
<h2>Interpret an Image</h2>
|
112 |
+
<input type="file" id="image-file" accept="image/*">
|
113 |
+
<button id="image-btn">Describe</button>
|
114 |
+
<div id="image-result" class="results">Image description will appear here.</div>
|
115 |
+
</div>
|
116 |
+
</div>
|
117 |
+
|
118 |
+
<script>
|
119 |
+
async function sendData(url, fileInputId, extraData, resultId) {
|
120 |
+
const fileInput = document.getElementById(fileInputId);
|
121 |
+
const file = fileInput.files[0];
|
122 |
+
if (!file) {
|
123 |
+
document.getElementById(resultId).textContent = 'Please select a file.';
|
124 |
+
return;
|
125 |
+
}
|
126 |
+
const formData = new FormData();
|
127 |
+
formData.append(fileInputId.includes('image') ? 'image' : 'file', file);
|
128 |
+
if (extraData) {
|
129 |
+
for (const [key, value] of Object.entries(extraData)) {
|
130 |
+
formData.append(key, value);
|
131 |
+
}
|
132 |
+
}
|
133 |
+
document.getElementById(resultId).textContent = 'Processing...';
|
134 |
+
try {
|
135 |
+
const res = await fetch(url, { method: 'POST', body: formData });
|
136 |
+
const data = await res.json();
|
137 |
+
document.getElementById(resultId).textContent = data.summary || data.answer || data.description || data.error || JSON.stringify(data);
|
138 |
+
} catch (err) {
|
139 |
+
document.getElementById(resultId).textContent = 'Error: ' + err.message;
|
140 |
+
}
|
141 |
+
}
|
142 |
+
|
143 |
+
document.getElementById('summarize-btn').addEventListener('click', () => {
|
144 |
+
sendData('/analyze', 'summary-file', null, 'summary-result');
|
145 |
+
});
|
146 |
+
|
147 |
+
document.getElementById('qa-btn').addEventListener('click', () => {
|
148 |
+
const question = document.getElementById('qa-question').value.trim();
|
149 |
+
if (!question) {
|
150 |
+
document.getElementById('qa-result').textContent = 'Please enter a question.';
|
151 |
+
return;
|
152 |
+
}
|
153 |
+
sendData('/ask', 'qa-file', { question }, 'qa-result');
|
154 |
+
});
|
155 |
+
|
156 |
+
document.getElementById('image-btn').addEventListener('click', () => {
|
157 |
+
sendData('/interpret_image', 'image-file', null, 'image-result');
|
158 |
+
});
|
159 |
+
</script>
|
160 |
+
</div>
|
161 |
+
</body>
|
162 |
+
</html>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|