Yash goyal commited on
Commit
bd8199f
·
verified ·
1 Parent(s): 457ff7b

Update templates/form.html

Browse files
Files changed (1) hide show
  1. templates/form.html +109 -170
templates/form.html CHANGED
@@ -1,195 +1,134 @@
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>SnapSkin</title>
7
- <link rel="stylesheet" href="/static/form-styles.css" />
8
- <link rel="shortcut icon" href="/static/logo.png" />
9
- <link href="https://fonts.googleapis.com/css2?family=Roboto:wght@300;400;500;700&display=swap" rel="stylesheet"/>
10
- <script src="/static/preloader.js"></script>
11
- <script src="/static/cursor-effect.js"></script>
12
- <script defer>
13
- document.addEventListener("DOMContentLoaded", () => {
14
- const fileInput = document.getElementById("image");
15
- const fileMessage = document.getElementById("upload-message");
16
- const submitBtn = document.getElementById("submit-btn");
17
- const emailBtn = document.getElementById("email-report-btn");
18
-
19
- fileInput.addEventListener("change", () => {
20
- const file = fileInput.files[0];
21
- fileMessage.style.display = "block";
22
-
23
- if (!file) {
24
- fileMessage.textContent = "No file selected.";
25
- fileMessage.style.color = "orange";
26
- submitBtn.disabled = true;
27
- return;
28
- }
29
-
30
- const allowedTypes = ["image/jpeg", "image/png"];
31
- const maxSize = 20 * 1024 * 1024; // 20MB
32
-
33
- if (!allowedTypes.includes(file.type)) {
34
- fileMessage.textContent = "Invalid file format. Use JPG or PNG.";
35
- fileMessage.style.color = "red";
36
- submitBtn.disabled = true;
37
- } else if (file.size > maxSize) {
38
- fileMessage.textContent = "File too large. Max 20MB allowed.";
39
- fileMessage.style.color = "red";
40
- submitBtn.disabled = true;
41
- } else {
42
- fileMessage.textContent = "✅ File ready for upload.";
43
- fileMessage.style.color = "limegreen";
44
- submitBtn.disabled = false;
45
- }
46
- });
47
-
48
- if (emailBtn) {
49
- emailBtn.addEventListener("click", async () => {
50
- const scanId = emailBtn.dataset.scanId;
51
- const emailStatus = document.getElementById("email-status");
52
- try {
53
- const response = await fetch(`/api/email-report/${scanId}`);
54
- const data = await response.json();
55
- emailStatus.textContent = data.message;
56
- emailStatus.style.color = data.success ? "limegreen" : "red";
57
- } catch (error) {
58
- emailStatus.textContent = "Error sending email.";
59
- emailStatus.style.color = "red";
60
- }
61
- });
62
- }
63
- });
64
- </script>
65
  </head>
66
  <body>
67
- <div class="preloader">
68
- <div class="preloader-particles"></div>
69
- <div class="dna-loader">
70
- <div class="dna-loader-strand"></div>
71
- <div class="dna-loader-strand"></div>
72
- <div class="dna-loader-rung"></div>
73
- <div class="dna-loader-rung"></div>
74
- <div class="dna-loader-rung"></div>
75
- <div class="dna-loader-rung"></div>
76
- <div class="dna-loader-rung"></div>
77
- <div class="dna-loader-rung"></div>
78
- <div class="dna-loader-rung"></div>
79
- <div class="dna-loader-rung"></div>
80
- <div class="loader-text">LOADING...</div>
81
- </div>
82
- </div>
83
-
84
- <header>
85
- <nav>
86
- <div class="logo" style="color: beige;">SNAP<span style="color: #00ffff;">SKIN</span></div>
87
- <ul>
88
- <li><a href="https://snapskin.vercel.app/">Home</a></li>
89
- </ul>
90
- </nav>
91
- </header>
92
-
93
- <section class="form-section">
94
  <div class="container">
95
- <div class="form-container">
96
- <h1 style="color: white;">ENTER PATIENT DETAILS</h1>
97
- <p class="intro-text">
98
- Fill out the form below for the diagnosis of your skin disease.
99
- Our AI will process your image and generate a predicted report for you.
100
- </p>
101
 
102
- <div class="form-wrapper">
103
- <form id="patient-form" action="/predict" method="POST" enctype="multipart/form-data">
104
  <div class="form-group">
105
- <label for="name">Full Name</label>
106
- <input type="text" id="name" name="name" placeholder="Enter your name" required />
107
  </div>
108
-
109
  <div class="form-group">
110
- <label for="email">Email Address</label>
111
- <input type="email" id="email" name="email" placeholder="Enter your email address" required />
112
  </div>
113
-
114
- <div class="form-row">
115
- <div class="form-group half">
116
- <label for="gender">Gender</label>
117
  <select id="gender" name="gender" required>
118
- <option value="" disabled selected>Select gender</option>
119
- <option value="male">Male</option>
120
- <option value="female">Female</option>
121
- <option value="other">Other</option>
122
  </select>
123
- </div>
124
-
125
- <div class="form-group half">
126
- <label for="age">Age</label>
127
- <input type="number" id="age" name="age" placeholder="Enter your age" min="1" max="120" required />
128
- </div>
129
  </div>
130
-
131
- <div class="form-group file-upload-group">
132
- <label for="image">Upload Image</label>
133
- <div class="file-upload-wrapper">
134
- <input type="file" id="image" name="image" accept=".jpg,.jpeg,.png" required />
135
- <span class="file-upload-text">Choose Image</span>
136
- </div>
137
- <small class="warning">Allowed: JPG, PNG | Max size: 20MB</small>
138
- <div class="upload-message" id="upload-message" style="display: none;"></div>
139
- </div>
140
-
141
- <div class="form-group consent-group">
142
- <input type="checkbox" id="consent" name="consent" required />
143
- <label for="consent">I agree to the <a href="#">Terms</a> and <a href="#">Privacy Policy</a></label>
144
  </div>
145
-
146
- <div class="form-actions">
147
- <button type="submit" class="submit-button" id="submit-btn">Submit Details</button>
148
  </div>
149
- </form>
 
150
 
151
- <!-- Result Section -->
152
- <div class="result-section" id="result-section" style="margin-top: 30px; {% if result %}display: block;{% else %}display: none;{% endif %}">
153
  <h2>Diagnosis Result</h2>
154
- <div id="result-content">
155
- {% if result %}
156
- <p><strong>Prediction:</strong> {{ result.prediction }}</p>
157
- <p><strong>Confidence:</strong> {{ result.confidence }}</p>
158
- {% if result.message %}
159
- <p class="warning-message">{{ result.message }}</p>
160
- {% endif %}
161
- <p id="email-status" style="color: {% if result.email_status contains 'Failed' %}red{% else %}limegreen{% endif %}">{{ result.email_status }}</p>
162
- <button id="email-report-btn" class="submit-button" data-scan-id="{{ result.scan_id }}">Resend Report to Email</button>
163
- {% endif %}
164
- </div>
165
- </div>
166
  </div>
167
- </div>
168
- </div>
169
- </section>
170
 
171
- <footer>
172
- <div class="container">
173
- <div class="footer-content">
174
- <div class="footer-logo">SNAP<span>SKIN</span></div>
175
- <div class="footer-links">
176
- <h3>Quick Links</h3>
177
- <ul>
178
- <li><a href="/form">Home</a></li>
179
- <li><a href="#">About</a></li>
180
- <li><a href="#">Features</a></li>
181
- </ul>
182
  </div>
183
- <div class="footer-contact">
184
- <h3>Support</h3>
185
- <p>Email: info.snapskin@gmail.com</p>
186
- <p>Phone: 7817833974 / 7983595318</p>
 
 
 
187
  </div>
188
- </div>
189
- <div class="copyright">
190
- <p>© 2025 SnapSkin. All rights reserved.</p>
191
- </div>
192
  </div>
193
- </footer>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
194
  </body>
195
  </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>SnapSkin - Skin Lesion Diagnosis</title>
7
+ <link rel="stylesheet" href="{{ url_for('static', filename='form-styles.css') }}">
8
+ <link rel="icon" type="image/png" href="{{ url_for('static', filename='logo.png') }}">
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
9
  </head>
10
  <body>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
11
  <div class="container">
12
+ <header>
13
+ <h1>SnapSkin</h1>
14
+ <p>AI-Powered Skin Lesion Diagnosis</p>
15
+ </header>
 
 
16
 
17
+ <form id="diagnosis-form" action="{{ url_for('predict') }}" method="POST" enctype="multipart/form-data">
 
18
  <div class="form-group">
19
+ <label for="name">Full Name:</label>
20
+ <input type="text" id="name" name="name" required>
21
  </div>
 
22
  <div class="form-group">
23
+ <label for="email">Email:</label>
24
+ <input type="email" id="email" name="email" required>
25
  </div>
26
+ <div class="form-group">
27
+ <label for="gender">Gender:</label>
 
 
28
  <select id="gender" name="gender" required>
29
+ <option value="Male">Male</option>
30
+ <option value="Female">Female</option>
31
+ <option value="Other">Other</option>
 
32
  </select>
 
 
 
 
 
 
33
  </div>
34
+ <div class="form-group">
35
+ <label for="age">Age:</label>
36
+ <input type="number" id="age" name="age" min="0" max="150" required>
 
 
 
 
 
 
 
 
 
 
 
37
  </div>
38
+ <div class="form-group">
39
+ <label for="image">Upload Skin Image:</label>
40
+ <input type="file" id="image" name="image" accept="image/*" required>
41
  </div>
42
+ <button type="submit" id="submit-btn">Diagnose</button>
43
+ </form>
44
 
45
+ {% if result %}
46
+ <div class="result">
47
  <h2>Diagnosis Result</h2>
48
+ <p><strong>Condition:</strong> {{ result.prediction }}</p>
49
+ <p><strong>Confidence:</strong> {{ result.confidence }}</p>
50
+ {% if result.message %}
51
+ <p><strong>Message:</strong> {{ result.message }}</p>
52
+ {% endif %}
53
+ <p id="email-status" style="color: {% if 'Failed' in result.email_status %}red{% else %}limegreen{% endif %}">{{ result.email_status }}</p>
54
+ {% if result.scan_id %}
55
+ <button id="resend-email-btn" data-scan-id="{{ result.scan_id }}">Resend Report to Email</button>
56
+ {% endif %}
57
+ <a href="{{ url_for('download_report') }}" id="download-btn">Download Report</a>
 
 
58
  </div>
59
+ {% endif %}
 
 
60
 
61
+ {% if history_plot %}
62
+ <div class="training-history">
63
+ <h2>Model Training History</h2>
64
+ <img src="{{ history_plot }}" alt="Training History Plot">
 
 
 
 
 
 
 
65
  </div>
66
+ {% endif %}
67
+
68
+ <div id="history-section">
69
+ <h2>Previous Scans</h2>
70
+ <input type="email" id="history-email" placeholder="Enter email to view history">
71
+ <button id="fetch-history-btn">View History</button>
72
+ <div id="history-results"></div>
73
  </div>
 
 
 
 
74
  </div>
75
+
76
+ <script src="{{ url_for('static', filename='preloader.js') }}"></script>
77
+ <script src="{{ url_for('static', filename='cursor-effect.js') }}"></script>
78
+ <script>
79
+ document.getElementById('fetch-history-btn').addEventListener('click', () => {
80
+ const email = document.getElementById('history-email').value;
81
+ if (!email) {
82
+ alert('Please enter an email address.');
83
+ return;
84
+ }
85
+ fetch(`/api/history?email=${encodeURIComponent(email)}`)
86
+ .then(response => response.json())
87
+ .then(data => {
88
+ const historyDiv = document.getElementById('history-results');
89
+ historyDiv.innerHTML = '';
90
+ if (data.length === 0) {
91
+ historyDiv.innerHTML = '<p>No scan history found for this email.</p>';
92
+ return;
93
+ }
94
+ const ul = document.createElement('ul');
95
+ data.forEach(scan => {
96
+ const li = document.createElement('li');
97
+ li.innerHTML = `
98
+ <p><strong>Scan ID:</strong> ${scan.id}</p>
99
+ <p><strong>Patient:</strong> ${scan.patient_name}</p>
100
+ <p><strong>Prediction:</strong> ${scan.prediction}</p>
101
+ <p><strong>Confidence:</strong> ${scan.confidence}</p>
102
+ <p><strong>Timestamp:</strong> ${scan.timestamp}</p>
103
+ <img src="${scan.image_url}" alt="Scan Image" style="max-width: 200px;">
104
+ <button onclick="resendEmail(${scan.id})">Resend Report</button>
105
+ `;
106
+ ul.appendChild(li);
107
+ });
108
+ historyDiv.appendChild(ul);
109
+ })
110
+ .catch(error => {
111
+ console.error('Error fetching history:', error);
112
+ document.getElementById('history-results').innerHTML = '<p>Error loading history. Please try again.</p>';
113
+ });
114
+ });
115
+
116
+ function resendEmail(scanId) {
117
+ fetch(`/api/email-report/${scanId}`)
118
+ .then(response => response.json())
119
+ .then(data => {
120
+ alert(data.message);
121
+ })
122
+ .catch(error => {
123
+ console.error('Error resending email:', error);
124
+ alert('Failed to resend report. Please try again.');
125
+ });
126
+ }
127
+
128
+ document.getElementById('resend-email-btn')?.addEventListener('click', () => {
129
+ const scanId = document.getElementById('resend-email-btn').getAttribute('data-scan-id');
130
+ resendEmail(scanId);
131
+ });
132
+ </script>
133
  </body>
134
  </html>