Spaces:
Running
Running
Update templates/index.html
Browse files- templates/index.html +128 -0
templates/index.html
CHANGED
|
@@ -78,6 +78,35 @@
|
|
| 78 |
{% endif %}
|
| 79 |
</div>
|
| 80 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 81 |
</div>
|
| 82 |
<div class="nav-button nav-button-info" id="info-button">
|
| 83 |
<div class="nav-button-inner">
|
|
@@ -181,6 +210,105 @@
|
|
| 181 |
</div>
|
| 182 |
</div>
|
| 183 |
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 184 |
</body>
|
| 185 |
|
| 186 |
</html>
|
|
|
|
| 78 |
{% endif %}
|
| 79 |
</div>
|
| 80 |
|
| 81 |
+
<div style="margin-top: 20px; border-top: 1px solid #ddd; padding-top: 20px;">μ΄λ―Έμ§ μ
λ‘λ</div>
|
| 82 |
+
<div class="upload-section" style="padding: 20px; background-color: #f5f5f5; border-radius: 8px; margin-top: 10px;">
|
| 83 |
+
<form id="upload-form" enctype="multipart/form-data">
|
| 84 |
+
<div style="margin-bottom: 15px;">
|
| 85 |
+
<label for="image-upload" style="display: block; margin-bottom: 5px; font-weight: 500;">μλ£ μμ μ ν:</label>
|
| 86 |
+
<input type="file" id="image-upload" name="image" accept=".png,.jpg,.jpeg,.gif,.bmp,.dcm,.dicom" required style="width: 100%; padding: 8px; border: 1px solid #ddd; border-radius: 4px;">
|
| 87 |
+
</div>
|
| 88 |
+
|
| 89 |
+
<div style="margin-bottom: 15px;">
|
| 90 |
+
<label for="image-type-select" style="display: block; margin-bottom: 5px; font-weight: 500;">μμ μ ν:</label>
|
| 91 |
+
<select id="image-type-select" name="image_type" style="width: 100%; padding: 8px; border: 1px solid #ddd; border-radius: 4px;">
|
| 92 |
+
<option value="CXR">νλΆ X-λ μ΄</option>
|
| 93 |
+
<option value="CT">CT</option>
|
| 94 |
+
<option value="OTHER">κΈ°ν μλ£ μμ</option>
|
| 95 |
+
</select>
|
| 96 |
+
</div>
|
| 97 |
+
|
| 98 |
+
<div style="margin-bottom: 15px;">
|
| 99 |
+
<label for="context-input" style="display: block; margin-bottom: 5px; font-weight: 500;">μΆκ° μ 보 (μ νμ¬ν):</label>
|
| 100 |
+
<textarea id="context-input" name="context" rows="3" placeholder="νμ μ¦μμ΄λ κ²μ¬ λͺ©μ λ±μ μ
λ ₯νμΈμ" style="width: 100%; padding: 8px; border: 1px solid #ddd; border-radius: 4px; resize: vertical;"></textarea>
|
| 101 |
+
</div>
|
| 102 |
+
|
| 103 |
+
<button type="submit" class="nav-button" style="width: 100%; padding: 12px; background-color: #4285f4; color: white; border: none; border-radius: 4px; font-size: 16px; cursor: pointer;">
|
| 104 |
+
<span class="material-symbols-outlined" style="vertical-align: middle; margin-right: 5px;">upload</span>
|
| 105 |
+
μμ λΆμνκΈ°
|
| 106 |
+
</button>
|
| 107 |
+
</form>
|
| 108 |
+
</div>
|
| 109 |
+
|
| 110 |
</div>
|
| 111 |
<div class="nav-button nav-button-info" id="info-button">
|
| 112 |
<div class="nav-button-inner">
|
|
|
|
| 210 |
</div>
|
| 211 |
</div>
|
| 212 |
</div>
|
| 213 |
+
|
| 214 |
+
<script>
|
| 215 |
+
// μ΄λ―Έμ§ μ
λ‘λ νΌ μ²λ¦¬
|
| 216 |
+
document.addEventListener('DOMContentLoaded', function() {
|
| 217 |
+
const uploadForm = document.getElementById('upload-form');
|
| 218 |
+
if (uploadForm) {
|
| 219 |
+
uploadForm.addEventListener('submit', async function(e) {
|
| 220 |
+
e.preventDefault();
|
| 221 |
+
|
| 222 |
+
const formData = new FormData(this);
|
| 223 |
+
const submitButton = this.querySelector('button[type="submit"]');
|
| 224 |
+
const originalButtonText = submitButton.innerHTML;
|
| 225 |
+
|
| 226 |
+
// λ‘λ© μν νμ
|
| 227 |
+
submitButton.disabled = true;
|
| 228 |
+
submitButton.innerHTML = '<span class="material-symbols-outlined" style="vertical-align: middle; margin-right: 5px;">hourglass_empty</span>λΆμ μ€...';
|
| 229 |
+
|
| 230 |
+
// κΈ°μ‘΄ μλ¬ λ©μμ§ μ κ±°
|
| 231 |
+
const errorDiv = document.getElementById('explanation-error');
|
| 232 |
+
if (errorDiv) {
|
| 233 |
+
errorDiv.style.display = 'none';
|
| 234 |
+
errorDiv.textContent = '';
|
| 235 |
+
}
|
| 236 |
+
|
| 237 |
+
try {
|
| 238 |
+
const response = await fetch('/upload_and_analyze', {
|
| 239 |
+
method: 'POST',
|
| 240 |
+
body: formData
|
| 241 |
+
});
|
| 242 |
+
|
| 243 |
+
const result = await response.json();
|
| 244 |
+
|
| 245 |
+
if (response.ok) {
|
| 246 |
+
// μ
λ‘λλ μ΄λ―Έμ§ νμ
|
| 247 |
+
const fileInput = document.getElementById('image-upload');
|
| 248 |
+
const file = fileInput.files[0];
|
| 249 |
+
if (file) {
|
| 250 |
+
const reader = new FileReader();
|
| 251 |
+
reader.onload = function(e) {
|
| 252 |
+
const reportImage = document.getElementById('report-image');
|
| 253 |
+
if (reportImage) {
|
| 254 |
+
reportImage.src = e.target.result;
|
| 255 |
+
reportImage.style.display = 'block';
|
| 256 |
+
}
|
| 257 |
+
};
|
| 258 |
+
reader.readAsDataURL(file);
|
| 259 |
+
}
|
| 260 |
+
|
| 261 |
+
// λΆμ κ²°κ³Ό νμ
|
| 262 |
+
const explanationContent = document.getElementById('explanation-content');
|
| 263 |
+
if (explanationContent) {
|
| 264 |
+
explanationContent.innerHTML = result.analysis.replace(/\n/g, '<br>');
|
| 265 |
+
}
|
| 266 |
+
|
| 267 |
+
// λ³΄κ³ μ ν
μ€νΈ μμμ μ
λ‘λ μ 보 νμ
|
| 268 |
+
const reportTextDisplay = document.getElementById('report-text-display');
|
| 269 |
+
if (reportTextDisplay) {
|
| 270 |
+
reportTextDisplay.innerHTML = '<div style="padding: 20px; background-color: #e8f4f8; border-radius: 8px;">' +
|
| 271 |
+
'<h3 style="margin-top: 0;">μ
λ‘λλ μμ λΆμ</h3>' +
|
| 272 |
+
'<p>νμΌλͺ
: ' + file.name + '</p>' +
|
| 273 |
+
'<p>μμ μ ν: ' + document.getElementById('image-type-select').selectedOptions[0].text + '</p>' +
|
| 274 |
+
(document.getElementById('context-input').value ? '<p>μΆκ° μ 보: ' + document.getElementById('context-input').value + '</p>' : '') +
|
| 275 |
+
'</div>';
|
| 276 |
+
}
|
| 277 |
+
|
| 278 |
+
// μ€λͺ
λ‘λ© λ©μμ§ μ¨κΈ°κΈ°
|
| 279 |
+
const explanationLoading = document.getElementById('explanation-loading');
|
| 280 |
+
if (explanationLoading) {
|
| 281 |
+
explanationLoading.style.display = 'none';
|
| 282 |
+
}
|
| 283 |
+
|
| 284 |
+
// μ΄λ―Έμ§ ν€λ μ
λ°μ΄νΈ
|
| 285 |
+
const imageHeader = document.getElementById('image-modality-header');
|
| 286 |
+
if (imageHeader) {
|
| 287 |
+
imageHeader.textContent = document.getElementById('image-type-select').selectedOptions[0].text;
|
| 288 |
+
}
|
| 289 |
+
|
| 290 |
+
} else {
|
| 291 |
+
// μλ¬ νμ
|
| 292 |
+
if (errorDiv) {
|
| 293 |
+
errorDiv.textContent = result.error || 'λΆμ μ€ μ€λ₯κ° λ°μνμ΅λλ€.';
|
| 294 |
+
errorDiv.style.display = 'block';
|
| 295 |
+
}
|
| 296 |
+
}
|
| 297 |
+
} catch (error) {
|
| 298 |
+
console.error('μ
λ‘λ μ€λ₯:', error);
|
| 299 |
+
if (errorDiv) {
|
| 300 |
+
errorDiv.textContent = 'λ€νΈμν¬ μ€λ₯κ° λ°μνμ΅λλ€. λ€μ μλν΄μ£ΌμΈμ.';
|
| 301 |
+
errorDiv.style.display = 'block';
|
| 302 |
+
}
|
| 303 |
+
} finally {
|
| 304 |
+
// λ²νΌ μλ μνλ‘ λ³΅μ
|
| 305 |
+
submitButton.disabled = false;
|
| 306 |
+
submitButton.innerHTML = originalButtonText;
|
| 307 |
+
}
|
| 308 |
+
});
|
| 309 |
+
}
|
| 310 |
+
});
|
| 311 |
+
</script>
|
| 312 |
</body>
|
| 313 |
|
| 314 |
</html>
|