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 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
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
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
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8" />
  <meta name="viewport" content="width=device-width, initial-scale=1.0"/>
  <title>SkinAI - Upload</title>
  <style>
    /* Reset */
    * {
      margin: 0;
      padding: 0;
      box-sizing: border-box;
    }

    body {
      font-family: Arial, sans-serif;
      background-color: #f5f8fa;
      color: #000;
    }

    /* Top Navigation with Enhanced Hover Effects */
    header {
      display: flex;
      align-items: center;
      justify-content: space-between;
      padding: 15px 5%;
      background-color: #fff;
      border-bottom: 1px solid #ccc;
      position: relative;
      z-index: 10;
    }
    
    .logo {
      font-size: 1.5rem;
      font-weight: bold;
      color: #333;
    }
    
    nav a {
      text-decoration: none;
      color: #333;
      margin-left: 20px;
      font-weight: 500;
      padding: 5px 0;
      position: relative;
      transition: color 0.3s ease;
    }
    
    /* Underline hover effect for nav links */
    nav a:after {
      content: '';
      position: absolute;
      width: 0;
      height: 2px;
      bottom: 0;
      left: 0;
      background-color: #007BFF;
      transition: width 0.3s ease;
    }
    
    nav a:hover {
      color: #007BFF;
      text-decoration: none;
    }
    
    nav a:hover:after {
      width: 100%;
    }
    
    .help-btn {
      background-color: #007BFF;
      color: #fff;
      border: none;
      padding: 8px 16px;
      border-radius: 4px;
      cursor: pointer;
      margin-left: 20px;
      transition: all 0.3s ease;
    }
    
    .help-btn:hover {
      background-color: #0056b3;
      transform: translateY(-2px);
      box-shadow: 0 4px 8px rgba(0,123,255,0.3);
    }

    /* Main Content Area */
    .container {
      max-width: 1200px;
      margin: 40px auto;
      padding: 0 20px;
    }

    /* Upload Section */
    .upload-section {
      background-color: #fff;
      border-radius: 10px;
      box-shadow: 0 5px 15px rgba(0,0,0,0.08);
      padding: 40px;
      margin-bottom: 40px;
      text-align: center;
    }

    .upload-section h1 {
      font-size: 2rem;
      color: #333;
      margin-bottom: 20px;
    }

    .upload-section p {
      font-size: 1.1rem;
      color: #666;
      margin-bottom: 30px;
      max-width: 700px;
      margin-left: auto;
      margin-right: auto;
    }

    /* Upload Area */
    .upload-area {
      border: 2px dashed #aac;
      border-radius: 10px;
      padding: 50px 20px;
      background-color: #f8faff;
      cursor: pointer;
      transition: all 0.3s ease;
      margin-bottom: 30px;
    }

    .upload-area:hover {
      border-color: #007BFF;
      background-color: #f0f8ff;
    }

    .upload-area.active {
      border-color: #007BFF;
      background-color: #e6f4ff;
    }

    .upload-icon {
      font-size: 3rem;
      color: #007BFF;
      margin-bottom: 15px;
    }

    .upload-text {
      font-size: 1.2rem;
      color: #666;
      margin-bottom: 10px;
    }

    .upload-subtext {
      font-size: 0.9rem;
      color: #888;
    }

    /* File Input */
    #file-input {
      display: none;
    }

    /* Preview Area */
    .preview-area {
      display: none;
      margin: 30px auto;
      max-width: 500px;
    }

    .preview-area img {
      max-width: 100%;
      max-height: 400px;
      border-radius: 8px;
      box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    }

    .preview-info {
      margin-top: 15px;
      font-size: 0.9rem;
      color: #666;
    }

    /* Button Styles */
    .btn {
      background-color: #007BFF;
      color: #fff;
      border: none;
      padding: 12px 24px;
      font-size: 1rem;
      border-radius: 4px;
      cursor: pointer;
      transition: all 0.3s ease;
      display: inline-block;
    }

    .btn:hover {
      background-color: #0056b3;
      transform: translateY(-2px);
      box-shadow: 0 4px 12px rgba(0,123,255,0.4);
    }

    .btn-secondary {
      background-color: #6c757d;
      margin-right: 10px;
    }

    .btn-secondary:hover {
      background-color: #5a6268;
    }

    /* Instructions Section */
    .instructions {
      background-color: #fff;
      border-radius: 10px;
      box-shadow: 0 5px 15px rgba(0,0,0,0.08);
      padding: 30px;
    }

    .instructions h2 {
      font-size: 1.5rem;
      color: #333;
      margin-bottom: 20px;
    }

    .instruction-cards {
      display: flex;
      flex-wrap: wrap;
      gap: 20px;
    }

    .instruction-card {
      flex: 1 1 300px;
      background-color: #f9f9f9;
      border-radius: 8px;
      padding: 20px;
      box-shadow: 0 2px 5px rgba(0,0,0,0.1);
      transition: all 0.3s ease;
      border-left: 3px solid transparent;
    }

    .instruction-card:hover {
      transform: translateY(-5px);
      box-shadow: 0 8px 15px rgba(0,0,0,0.1);
      border-left: 3px solid #007BFF;
    }

    .instruction-card h3 {
      font-size: 1.1rem;
      color: #333;
      margin-bottom: 10px;
    }

    .instruction-card p {
      font-size: 0.95rem;
      color: #666;
      line-height: 1.5;
    }

    /* Footer */
    footer {
      text-align: center;
      padding: 20px;
      margin-top: 40px;
      color: #777;
      font-size: 0.9rem;
    }

    /* Responsive */
    @media (max-width: 768px) {
      .container {
        padding: 0 15px;
        margin: 20px auto;
      }
      
      .upload-section {
        padding: 30px 15px;
      }
      
      .upload-section h1 {
        font-size: 1.7rem;
      }
      
      .upload-area {
        padding: 30px 15px;
      }
      
      .instructions {
        padding: 20px 15px;
      }
    }
  </style>
</head>
<body>

  <!-- Top Navigation -->
  <header>
    <div class="logo">SkinAI</div>
    <nav>
      <a href="/">Home</a>
      <a href="/upload" style="color: #007BFF;">Upload</a>
      <a href="/result">Results</a>
      <a href="#">Contact</a>
      <button class="help-btn">Help</button>
    </nav>
  </header>

  <div class="container">
    <!-- Upload Section -->
    <section class="upload-section">
      <h1>Upload Your Skin Image</h1>
      <p>Our AI will analyze your image and provide insights about potential skin conditions. Please upload a clear, well-lit photo of the affected area.</p>
      
      <!-- Upload Area -->
      <div class="upload-area" id="drop-area">
        <div class="upload-icon">📤</div>
        <div class="upload-text">Drag & Drop your image here</div>
        <div class="upload-subtext">or click to browse files</div>
        <input type="file" id="file-input" accept="image/*">
      </div>
      
      <!-- Preview Area (initially hidden) -->
      <div class="preview-area" id="preview-area">
        <img id="preview-image" src="#" alt="Preview">
        <div class="preview-info" id="file-info">File information will appear here</div>
        <div style="margin-top: 20px;">
          <button class="btn btn-secondary" id="cancel-btn">Cancel</button>
          <button class="btn" id="analyze-btn">Analyze Image</button>
        </div>
      </div>
    </section>
    
    <!-- Instructions Section -->
    <section class="instructions">
      <h2>Best Practices for Accurate Results</h2>
      <div class="instruction-cards">
        <!-- Instruction 1 -->
        <div class="instruction-card">
          <h3>Good Lighting</h3>
          <p>Ensure your photo is taken in bright, natural light. Avoid shadows or harsh lighting that might distort colors or details.</p>
        </div>
        <!-- Instruction 2 -->
        <div class="instruction-card">
          <h3>Clear Focus</h3>
          <p>Take a clear, in-focus image of the affected area. Blurry images may lead to inaccurate results.</p>
        </div>
        <!-- Instruction 3 -->
        <div class="instruction-card">
          <h3>Proper Distance</h3>
          <p>Capture the image from about 6-12 inches away to show sufficient detail while maintaining context of the affected area.</p>
        </div>
      </div>
    </section>
  </div>

  <footer>
    <p>© 2025 SkinAI. All rights reserved. For educational purposes only. Not a substitute for professional medical advice.</p>
  </footer>

  <script>
    // JavaScript for handling file uploads and preview
   // JavaScript for handling file uploads, preview, and analysis
document.addEventListener('DOMContentLoaded', function() {
  const dropArea = document.getElementById('drop-area');
  const fileInput = document.getElementById('file-input');
  const previewArea = document.getElementById('preview-area');
  const previewImage = document.getElementById('preview-image');
  const fileInfo = document.getElementById('file-info');
  const cancelBtn = document.getElementById('cancel-btn');
  const analyzeBtn = document.getElementById('analyze-btn');
  
  // Open file browser when clicking the upload area
  dropArea.addEventListener('click', () => {
    fileInput.click();
  });
  
  // Handle file selection
  fileInput.addEventListener('change', handleFiles);
  
  // Prevent default drag behaviors
  ['dragenter', 'dragover', 'dragleave', 'drop'].forEach(eventName => {
    dropArea.addEventListener(eventName, preventDefaults, false);
    document.body.addEventListener(eventName, preventDefaults, false);
  });
  
  // Highlight drop area when dragging over it
  ['dragenter', 'dragover'].forEach(eventName => {
    dropArea.addEventListener(eventName, highlight, false);
  });
  
  ['dragleave', 'drop'].forEach(eventName => {
    dropArea.addEventListener(eventName, unhighlight, false);
  });
  
  // Handle dropped files
  dropArea.addEventListener('drop', handleDrop, false);
  
  // Cancel button functionality
  cancelBtn.addEventListener('click', () => {
    resetUpload();
  });
  
  // Analyze button functionality - send to backend
  analyzeBtn.addEventListener('click', () => {
    sendImageForAnalysis();
  });
  
  // Functions
  function preventDefaults(e) {
    e.preventDefault();
    e.stopPropagation();
  }
  
  function highlight() {
    dropArea.classList.add('active');
  }
  
  function unhighlight() {
    dropArea.classList.remove('active');
  }
  
  function handleDrop(e) {
    const dt = e.dataTransfer;
    const files = dt.files;
    handleFiles(files);
  }
  
  function handleFiles(e) {
    const files = this.files || e;
    if (files && files[0]) {
      const file = files[0];
      
      // Check if it's an image
      if (!file.type.match('image.*')) {
        alert('Please upload an image file');
        return;
      }
      
      // Display file info
      const size = (file.size / 1024).toFixed(2);
      fileInfo.textContent = `${file.name} (${size} KB)`;
      
      // Show preview
      const reader = new FileReader();
      reader.onload = function(e) {
        previewImage.src = e.target.result;
        dropArea.style.display = 'none';
        previewArea.style.display = 'block';
        
        // Store image data for results page
        sessionStorage.setItem('analyzedImage', e.target.result);
      }
      reader.readAsDataURL(file);
    }
  }
  
  function resetUpload() {
    fileInput.value = '';
    previewImage.src = '#';
    previewArea.style.display = 'none';
    dropArea.style.display = 'block';
    
    // Clear session storage data
    sessionStorage.removeItem('analyzedImage');
    sessionStorage.removeItem('analysisResult');
    sessionStorage.removeItem('detectedCondition');
  }
  
  function sendImageForAnalysis() {
    // Show loading state
    analyzeBtn.disabled = true;
    analyzeBtn.textContent = 'Analyzing...';
    
    // Get the file
    const file = fileInput.files[0];
    if (!file) {
      alert('Please select an image first');
      analyzeBtn.disabled = false;
      analyzeBtn.textContent = 'Analyze Image';
      return;
    }
    
    // Create FormData object
    const formData = new FormData();
    formData.append('image', file);
    
    // Send to backend
    fetch('/analyze',  {
      method: 'POST',
      body: formData
    })
    .then(response => {
      if (!response.ok) {
        throw new Error('Network response was not ok');
      }
      return response.json();
    })
    .then(result => {
      // Store result in session storage
      sessionStorage.setItem('analysisResult', JSON.stringify(result));
      sessionStorage.setItem('detectedCondition', result.prediction || '');
      
      // Redirect to results page
      window.location.href = 'result';
    })
    .catch(error => {
      console.error('Error:', error);
      alert('There was an error analyzing your image. Please try again.');
      
      // Reset button state
      analyzeBtn.disabled = false;
      analyzeBtn.textContent = 'Analyze Image';
    });
  }
});
  </script>

</body>
</html>