Yash goyal commited on
Update templates/form.html
Browse files- templates/form.html +109 -170
templates/form.html
CHANGED
|
@@ -1,195 +1,134 @@
|
|
| 1 |
<!DOCTYPE html>
|
| 2 |
<html lang="en">
|
| 3 |
<head>
|
| 4 |
-
|
| 5 |
-
|
| 6 |
-
|
| 7 |
-
|
| 8 |
-
|
| 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 |
-
|
| 96 |
-
|
| 97 |
-
|
| 98 |
-
|
| 99 |
-
Our AI will process your image and generate a predicted report for you.
|
| 100 |
-
</p>
|
| 101 |
|
| 102 |
-
<
|
| 103 |
-
<form id="patient-form" action="/predict" method="POST" enctype="multipart/form-data">
|
| 104 |
<div class="form-group">
|
| 105 |
-
|
| 106 |
-
|
| 107 |
</div>
|
| 108 |
-
|
| 109 |
<div class="form-group">
|
| 110 |
-
|
| 111 |
-
|
| 112 |
</div>
|
| 113 |
-
|
| 114 |
-
|
| 115 |
-
<div class="form-group half">
|
| 116 |
-
<label for="gender">Gender</label>
|
| 117 |
<select id="gender" name="gender" required>
|
| 118 |
-
|
| 119 |
-
|
| 120 |
-
|
| 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 |
-
|
| 132 |
-
|
| 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 |
-
|
| 147 |
-
|
| 148 |
</div>
|
| 149 |
-
|
|
|
|
| 150 |
|
| 151 |
-
|
| 152 |
-
|
| 153 |
<h2>Diagnosis Result</h2>
|
| 154 |
-
<
|
| 155 |
-
|
| 156 |
-
|
| 157 |
-
|
| 158 |
-
|
| 159 |
-
|
| 160 |
-
|
| 161 |
-
|
| 162 |
-
|
| 163 |
-
|
| 164 |
-
</div>
|
| 165 |
-
</div>
|
| 166 |
</div>
|
| 167 |
-
|
| 168 |
-
</div>
|
| 169 |
-
</section>
|
| 170 |
|
| 171 |
-
|
| 172 |
-
|
| 173 |
-
|
| 174 |
-
|
| 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 |
-
|
| 184 |
-
|
| 185 |
-
|
| 186 |
-
|
|
|
|
|
|
|
|
|
|
| 187 |
</div>
|
| 188 |
-
</div>
|
| 189 |
-
<div class="copyright">
|
| 190 |
-
<p>© 2025 SnapSkin. All rights reserved.</p>
|
| 191 |
-
</div>
|
| 192 |
</div>
|
| 193 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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>
|