seawolf2357 commited on
Commit
6af9062
·
verified ·
1 Parent(s): 5988bc4

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +18 -40
app.py CHANGED
@@ -452,9 +452,9 @@ def load_session_history(selected_session):
452
  formatted_time = datetime.strptime(timestamp, '%Y-%m-%d %H:%M:%S.%f').strftime('%Y-%m-%d %H:%M')
453
 
454
  js_data.append({
455
- 'prompt': prompt,
456
- 'response': response,
457
- 'short_prompt': short_prompt,
458
  'timestamp': formatted_time
459
  })
460
 
@@ -477,38 +477,21 @@ def load_session_history(selected_session):
477
  const textarea = document.querySelector('textarea');
478
  if (textarea) {{
479
  textarea.value = item.prompt;
480
- }}
481
-
482
- // 코드 추출 및 실행
483
- let code = item.response;
484
- if (code.includes('```html')) {{
485
- const match = code.match(/```html\\n([\\s\\S]*?)\\n```/);
486
- if (match) {{
487
- code = match[1];
 
 
 
 
 
 
488
  }}
489
- }}
490
-
491
- // iframe 업데이트
492
- const encodedHtml = btoa(unescape(encodeURIComponent(code.trim())));
493
- const dataUri = `data:text/html;charset=utf-8;base64,${{encodedHtml}}`;
494
-
495
- const iframe = document.querySelector('.html_content iframe');
496
- if (iframe) {{
497
- iframe.src = dataUri;
498
- }}
499
-
500
- // 실행 버튼 클릭
501
- const executeButton = Array.from(document.querySelectorAll('button')).find(
502
- button => button.textContent.includes('Code 실행')
503
- );
504
- if (executeButton) {{
505
- executeButton.click();
506
- }}
507
-
508
- // 드로어 닫기
509
- const drawer = document.querySelector('.session-drawer');
510
- if (drawer) {{
511
- drawer.style.display = 'none';
512
  }}
513
  }}
514
  </script>
@@ -875,12 +858,7 @@ with gr.Blocks(css_paths="app.css",theme=theme) as demo:
875
  outputs=[session_drawer, session_list, session_history]
876
  )
877
 
878
- # 세션 히스토리 이벤트 핸들러
879
- session_history.select(
880
- fn=handle_history_selection,
881
- inputs=[],
882
- outputs=[input, sandbox, state_tab, session_drawer]
883
- )
884
 
885
 
886
  session_list.change(
 
452
  formatted_time = datetime.strptime(timestamp, '%Y-%m-%d %H:%M:%S.%f').strftime('%Y-%m-%d %H:%M')
453
 
454
  js_data.append({
455
+ 'prompt': html.escape(prompt),
456
+ 'response': html.escape(response),
457
+ 'short_prompt': html.escape(short_prompt),
458
  'timestamp': formatted_time
459
  })
460
 
 
477
  const textarea = document.querySelector('textarea');
478
  if (textarea) {{
479
  textarea.value = item.prompt;
480
+
481
+ // Code 실행 버튼 찾기 및 클릭
482
+ const buttons = document.querySelectorAll('button');
483
+ for (const button of buttons) {{
484
+ if (button.textContent.includes('Code 실행')) {{
485
+ setTimeout(() => button.click(), 100);
486
+ break;
487
+ }}
488
+ }}
489
+
490
+ // 드로어 닫기
491
+ const drawer = document.querySelector('.session-drawer');
492
+ if (drawer) {{
493
+ drawer.style.display = 'none';
494
  }}
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
495
  }}
496
  }}
497
  </script>
 
858
  outputs=[session_drawer, session_list, session_history]
859
  )
860
 
861
+
 
 
 
 
 
862
 
863
 
864
  session_list.change(