RushiMane2003 commited on
Commit
13dbb80
·
verified ·
1 Parent(s): 6cacd85

Update templates/index.html

Browse files
Files changed (1) hide show
  1. templates/index.html +343 -0
templates/index.html CHANGED
@@ -0,0 +1,343 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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">
6
+ <title>Soil Report Analysis & Recommendations Generator</title>
7
+ <!-- Include Chart.js library -->
8
+ <script src="https://cdn.jsdelivr.net/npm/chart.js"></script>
9
+ <style>
10
+ :root {
11
+ --primary-color: #007BFF;
12
+ --primary-dark: #0056b3;
13
+ --secondary-color: #2c5282;
14
+ --bg-color: #f4f4f4;
15
+ --text-color: #333;
16
+ --white: #ffffff;
17
+ --error-bg: #f8d7da;
18
+ --error-text: #721c24;
19
+ --container-bg: #ffffff;
20
+ --shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
21
+ /* Distinct section background colors */
22
+ --section-bg-overview: #e0f7fa;
23
+ --section-bg-composition: #ffe0b2;
24
+ --section-bg-nutrients: #c8e6c9;
25
+ --section-bg-ph: #f3e5f5;
26
+ --section-bg-recommendations: #d1c4e9;
27
+ }
28
+
29
+ /* Base Styles */
30
+ body {
31
+ font-family: 'Roboto', sans-serif;
32
+ background-color: var(--bg-color);
33
+ margin: 0;
34
+ padding: 0;
35
+ color: var(--text-color);
36
+ }
37
+
38
+ .container {
39
+ max-width: 900px;
40
+ margin: 50px auto;
41
+ background: var(--container-bg);
42
+ padding: 30px;
43
+ border-radius: 10px;
44
+ box-shadow: var(--shadow);
45
+ }
46
+
47
+ /* Title and Header */
48
+ .main-title {
49
+ font-size: 2.5rem;
50
+ text-align: center;
51
+ margin-bottom: 30px;
52
+ display: flex;
53
+ align-items: center;
54
+ justify-content: center;
55
+ color: var(--secondary-color);
56
+ }
57
+
58
+ .title-icon {
59
+ font-size: 2.5rem;
60
+ margin-right: 10px;
61
+ }
62
+
63
+ /* Upload Section */
64
+ .upload-section {
65
+ background: var(--white);
66
+ padding: 25px;
67
+ border-radius: 10px;
68
+ margin-bottom: 30px;
69
+ box-shadow: var(--shadow);
70
+ }
71
+
72
+ .upload-section h2 {
73
+ text-align: center;
74
+ margin-bottom: 20px;
75
+ color: var(--secondary-color);
76
+ }
77
+
78
+ .file-input-container {
79
+ border: 2px dashed #cbd5e1;
80
+ padding: 30px;
81
+ border-radius: 10px;
82
+ text-align: center;
83
+ transition: border-color 0.3s ease;
84
+ cursor: pointer;
85
+ }
86
+
87
+ .file-input-container:hover {
88
+ border-color: var(--primary-color);
89
+ }
90
+
91
+ /* Button Styles */
92
+ button,
93
+ .upload-button {
94
+ background-color: var(--primary-color);
95
+ color: var(--white);
96
+ padding: 12px 24px;
97
+ border: none;
98
+ border-radius: 5px;
99
+ font-size: 1rem;
100
+ cursor: pointer;
101
+ display: block;
102
+ width: 100%;
103
+ transition: background-color 0.3s ease;
104
+ margin-top: 20px;
105
+ }
106
+
107
+ .upload-button:hover {
108
+ background-color: var(--primary-dark);
109
+ }
110
+
111
+ /* Loading Spinner */
112
+ .loading {
113
+ text-align: center;
114
+ margin: 20px 0;
115
+ }
116
+
117
+ .loading-spinner {
118
+ width: 40px;
119
+ height: 40px;
120
+ border: 4px solid #f3f3f3;
121
+ border-top: 4px solid var(--primary-color);
122
+ border-radius: 50%;
123
+ animation: spin 1s linear infinite;
124
+ margin: 20px auto;
125
+ }
126
+
127
+ @keyframes spin {
128
+ to {
129
+ transform: rotate(360deg);
130
+ }
131
+ }
132
+
133
+ /* Flash Messages */
134
+ .flash-message {
135
+ background-color: var(--error-bg);
136
+ color: var(--error-text);
137
+ padding: 10px 15px;
138
+ border-radius: 5px;
139
+ margin-bottom: 20px;
140
+ text-align: center;
141
+ }
142
+
143
+ /* Markdown Content Styling */
144
+ .markdown-body {
145
+ background-color: var(--white);
146
+ padding: 30px;
147
+ border-radius: 8px;
148
+ border: 1px solid #e1e4e8;
149
+ margin-top: 20px;
150
+ line-height: 1.6;
151
+ }
152
+
153
+ /* Section Heading Styles with distinct colors */
154
+ .markdown-body h1 {
155
+ background-color: var(--section-bg-overview);
156
+ padding: 10px;
157
+ border-radius: 5px;
158
+ }
159
+
160
+ .markdown-body h2:nth-of-type(1) {
161
+ background-color: var(--section-bg-overview);
162
+ padding: 8px;
163
+ border-radius: 5px;
164
+ }
165
+
166
+ .markdown-body h2:nth-of-type(2) {
167
+ background-color: var(--section-bg-composition);
168
+ padding: 8px;
169
+ border-radius: 5px;
170
+ }
171
+
172
+ .markdown-body h2:nth-of-type(3) {
173
+ background-color: var(--section-bg-nutrients);
174
+ padding: 8px;
175
+ border-radius: 5px;
176
+ }
177
+
178
+ .markdown-body h2:nth-of-type(4) {
179
+ background-color: var(--section-bg-ph);
180
+ padding: 8px;
181
+ border-radius: 5px;
182
+ }
183
+
184
+ .markdown-body h2:nth-of-type(5) {
185
+ background-color: var(--section-bg-recommendations);
186
+ padding: 8px;
187
+ border-radius: 5px;
188
+ }
189
+
190
+ /* Ensure canvas fills the container */
191
+ #chartContainer canvas {
192
+ max-width: 100%;
193
+ }
194
+
195
+ /* Responsive Adjustments */
196
+ @media (max-width: 768px) {
197
+ .container {
198
+ margin: 20px;
199
+ padding: 20px;
200
+ }
201
+
202
+ .main-title {
203
+ font-size: 2rem;
204
+ }
205
+
206
+ .upload-button {
207
+ font-size: 0.9rem;
208
+ padding: 10px;
209
+ }
210
+
211
+ .file-input-container {
212
+ padding: 20px;
213
+ }
214
+ }
215
+ #chartContainer {
216
+ margin-top: 20px;
217
+ padding: 20px;
218
+ background-color: #f9f9f9;
219
+ border: 1px solid #ddd;
220
+ border-radius: 5px;
221
+ display: none; /* Initially hidden until chart code is executed */
222
+ }
223
+ #chartContainer canvas {
224
+ max-width: 100%;
225
+ }
226
+ </style>
227
+ </head>
228
+ <body>
229
+ <div class="container">
230
+ <h1 class="main-title">
231
+ <span class="title-icon">🌱</span>
232
+ Soil Report Analysis & Recommendations Generator
233
+ </h1>
234
+
235
+ {% with messages = get_flashed_messages() %}
236
+ {% if messages %}
237
+ {% for message in messages %}
238
+ <div class="flash-message">{{ message }}</div>
239
+ {% endfor %}
240
+ {% endif %}
241
+ {% endwith %}
242
+
243
+ <div class="upload-section">
244
+ <h2>Upload Soil Reports</h2>
245
+ <form id="uploadForm">
246
+ <div class="file-input-container">
247
+ <input type="file" name="files" accept=".pdf,.jpg,.jpeg,.png" multiple required>
248
+ <p>Drag & drop your soil reports here or click to select</p>
249
+ </div>
250
+ <div class="mb-4">
251
+ <label for="language" class="form-label">Response Language</label>
252
+ <select class="form-control" id="language" name="language" required>
253
+ <option value="English">English</option>
254
+ <option value="Hindi">Hindi</option>
255
+ <option value="Bengali">Bengali</option>
256
+ <option value="Telugu">Telugu</option>
257
+ <option value="Marathi">Marathi</option>
258
+ <option value="Tamil">Tamil</option>
259
+ <option value="Gujarati">Gujarati</option>
260
+ <option value="Urdu">Urdu</option>
261
+ <option value="Kannada">Kannada</option>
262
+ <option value="Odia">Odia</option>
263
+ <option value="Malayalam">Malayalam</option>
264
+ </select>
265
+ </div>
266
+ <button type="submit" class="upload-button">Generate Soil Analysis & Recommendations</button>
267
+ </form>
268
+ </div>
269
+
270
+
271
+ <div class="loading" id="loading" style="display:none;">
272
+ <div class="loading-spinner"></div>
273
+ <p>Analyzing soil reports and generating analysis...</p>
274
+ </div>
275
+
276
+ <div id="summaryContainer" class="markdown-body" style="display: none;"></div>
277
+ <!-- Chart Container with a canvas element -->
278
+ <div id="chartContainer">
279
+ <canvas id="myChart"></canvas>
280
+ </div>
281
+ </div>
282
+
283
+ <script>
284
+ document.getElementById('uploadForm').addEventListener('submit', function(e) {
285
+ e.preventDefault();
286
+ const formData = new FormData(this);
287
+ const loading = document.getElementById('loading');
288
+ const summaryContainer = document.getElementById('summaryContainer');
289
+ const chartContainer = document.getElementById('chartContainer');
290
+
291
+ loading.style.display = 'block';
292
+ summaryContainer.style.display = 'none';
293
+ chartContainer.style.display = 'none';
294
+
295
+ fetch('/', { method: 'POST', body: formData })
296
+ .then(response => response.json())
297
+ .then(data => {
298
+ loading.style.display = 'none';
299
+ summaryContainer.style.display = 'block';
300
+ if (data.error) {
301
+ summaryContainer.innerHTML = `<div class="flash-message">${data.error}</div>`;
302
+ } else {
303
+ summaryContainer.innerHTML = data.html_summary;
304
+ if (data.chart_img) {
305
+ chartContainer.style.display = 'block';
306
+ chartContainer.innerHTML = `<img src="${data.chart_img}" alt="Nutrient Chart" style="max-width:100%;"/>`;
307
+ }
308
+ }
309
+ })
310
+ .catch(error => {
311
+ loading.style.display = 'none';
312
+ summaryContainer.style.display = 'block';
313
+ summaryContainer.innerHTML = `<div class="flash-message">Error: ${error.message}</div>`;
314
+ });
315
+ });
316
+
317
+ // Drag and drop functionality
318
+ const fileInput = document.querySelector('input[type="file"]');
319
+ const dropZone = document.querySelector('.file-input-container');
320
+ ['dragenter', 'dragover', 'dragleave', 'drop'].forEach(eventName => {
321
+ dropZone.addEventListener(eventName, preventDefaults, false);
322
+ });
323
+ function preventDefaults(e) {
324
+ e.preventDefault();
325
+ e.stopPropagation();
326
+ }
327
+ ['dragenter', 'dragover'].forEach(eventName => {
328
+ dropZone.addEventListener(eventName, highlight, false);
329
+ });
330
+ ['dragleave', 'drop'].forEach(eventName => {
331
+ dropZone.addEventListener(eventName, unhighlight, false);
332
+ });
333
+ function highlight(e) { dropZone.style.borderColor = '#3b82f6'; }
334
+ function unhighlight(e) { dropZone.style.borderColor = '#cbd5e1'; }
335
+ dropZone.addEventListener('drop', handleDrop, false);
336
+ function handleDrop(e) {
337
+ const dt = e.dataTransfer;
338
+ const files = dt.files;
339
+ fileInput.files = files;
340
+ }
341
+ </script>
342
+ </body>
343
+ </html>