seawolf2357 commited on
Commit
d611dbe
·
verified ·
1 Parent(s): 780f64d

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +9 -6
app.py CHANGED
@@ -429,8 +429,6 @@ def load_session_history(selected_session=None):
429
  json_data = load_json_data()
430
  print(f"Loaded {len(json_data)} items from JSON")
431
 
432
- current_dir = os.path.dirname(os.path.abspath(__file__))
433
-
434
  html_content = """
435
  <style>
436
  .prompt-grid {
@@ -479,15 +477,20 @@ def load_session_history(selected_session=None):
479
 
480
  for item in json_data:
481
  name = html.escape(item.get('name', ''))
482
- image_url = os.path.join(current_dir, item.get('image_url', ''))
483
  prompt = html.escape(item.get('prompt', ''))
484
 
485
- print(f"Processing item: {name}")
486
- print(f"Image path: {image_url}")
 
 
 
 
 
487
 
488
  html_content += f"""
489
  <div class="prompt-card" data-prompt="{prompt}" onclick="handleCardClick(this)">
490
- <img src="{image_url}" class="card-image" alt="{name}" onerror="this.src='default.png'">
491
  <div class="card-name">{name}</div>
492
  <div class="card-prompt">{prompt}</div>
493
  </div>
 
429
  json_data = load_json_data()
430
  print(f"Loaded {len(json_data)} items from JSON")
431
 
 
 
432
  html_content = """
433
  <style>
434
  .prompt-grid {
 
477
 
478
  for item in json_data:
479
  name = html.escape(item.get('name', ''))
480
+ image_path = item.get('image_url', '')
481
  prompt = html.escape(item.get('prompt', ''))
482
 
483
+ # 이미지를 base64로 인코딩
484
+ try:
485
+ image_data = get_image_base64(image_path)
486
+ image_url = f"data:image/png;base64,{image_data}"
487
+ except Exception as e:
488
+ print(f"Error loading image {image_path}: {e}")
489
+ image_url = "data:image/png;base64," + get_image_base64('default.png') # 기본 이미지
490
 
491
  html_content += f"""
492
  <div class="prompt-card" data-prompt="{prompt}" onclick="handleCardClick(this)">
493
+ <img src="{image_url}" class="card-image" alt="{name}">
494
  <div class="card-name">{name}</div>
495
  <div class="card-prompt">{prompt}</div>
496
  </div>