ariankhalfani commited on
Commit
9bb0397
1 Parent(s): 5e6a1f4

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +27 -11
app.py CHANGED
@@ -167,18 +167,34 @@ def add_text_and_watermark(image, name, age, medical_record, sex, label):
167
 
168
  # Function to append patient info and image to HTML database
169
  def append_patient_info_to_html(name, age, medical_record, sex, result, predicted_image_base64):
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
170
  html_entry = f"""
171
- <div>
172
- <h2>Patient Information</h2>
173
- <p><strong>Name:</strong> {name}</p>
174
- <p><strong>Age:</strong> {age}</p>
175
- <p><strong>Medical Record:</strong> {medical_record}</p>
176
- <p><strong>Sex:</strong> {sex}</p>
177
- <p><strong>Result:</strong> {result}</p>
178
- <p><strong>Predicted Image:</strong></p>
179
- <img src="data:image/png;base64,{predicted_image_base64}" alt="Predicted Image" width="300">
180
- </div>
181
- <hr>
182
  """
183
 
184
  with open(html_db_file, 'a') as f:
 
167
 
168
  # Function to append patient info and image to HTML database
169
  def append_patient_info_to_html(name, age, medical_record, sex, result, predicted_image_base64):
170
+ # Check if the table header is already present
171
+ if os.stat(html_db_file).st_size == 0: # Empty file, need to create the table structure
172
+ with open(html_db_file, 'a') as f:
173
+ f.write("""
174
+ <html>
175
+ <body>
176
+ <h1>Patient Prediction Database</h1>
177
+ <table border="1" style="width:100%; border-collapse: collapse;">
178
+ <tr>
179
+ <th>Name</th>
180
+ <th>Age</th>
181
+ <th>Medical Record</th>
182
+ <th>Sex</th>
183
+ <th>Result</th>
184
+ <th>Predicted Image</th>
185
+ </tr>
186
+ """)
187
+
188
+ # Append patient data as a new row in the table
189
  html_entry = f"""
190
+ <tr>
191
+ <td>{name}</td>
192
+ <td>{age}</td>
193
+ <td>{medical_record}</td>
194
+ <td>{sex}</td>
195
+ <td>{result}</td>
196
+ <td><img src="data:image/png;base64,{predicted_image_base64}" alt="Predicted Image" width="150"></td>
197
+ </tr>
 
 
 
198
  """
199
 
200
  with open(html_db_file, 'a') as f: