seawolf2357 commited on
Commit
2907ab6
Β·
verified Β·
1 Parent(s): ea7bf73

Update templates/index.html

Browse files
Files changed (1) hide show
  1. 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>