Update app.py
Browse files
app.py
CHANGED
@@ -605,6 +605,25 @@ with gr.Blocks(css_paths="app.css",theme=theme) as demo:
|
|
605 |
with antd.Tabs.Item(key="render"):
|
606 |
sandbox = gr.HTML(elem_classes="html_content")
|
607 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
608 |
# ์ด๋ฒคํธ ํธ๋ค๋ฌ๋ค
|
609 |
execute_btn.click(
|
610 |
fn=execute_code,
|
|
|
605 |
with antd.Tabs.Item(key="render"):
|
606 |
sandbox = gr.HTML(elem_classes="html_content")
|
607 |
|
608 |
+
# Code ์คํ ๋ฒํผ ์ด๋ฒคํธ ํธ๋ค๋ฌ ํจ์ ์ ์
|
609 |
+
def execute_code(query: str):
|
610 |
+
if not query or query.strip() == '':
|
611 |
+
return None, gr.update(active_key="empty")
|
612 |
+
|
613 |
+
try:
|
614 |
+
# HTML ์ฝ๋ ๋ธ๋ก ํ์ธ
|
615 |
+
if '```html' in query and '```' in query:
|
616 |
+
# HTML ์ฝ๋ ๋ธ๋ก ์ถ์ถ
|
617 |
+
code = remove_code_block(query)
|
618 |
+
else:
|
619 |
+
# ์
๋ ฅ๋ ํ
์คํธ๋ฅผ ๊ทธ๋๋ก ์ฝ๋๋ก ์ฌ์ฉ
|
620 |
+
code = query.strip()
|
621 |
+
|
622 |
+
return send_to_sandbox(code), gr.update(active_key="render")
|
623 |
+
except Exception as e:
|
624 |
+
print(f"Error executing code: {str(e)}")
|
625 |
+
return None, gr.update(active_key="empty")
|
626 |
+
|
627 |
# ์ด๋ฒคํธ ํธ๋ค๋ฌ๋ค
|
628 |
execute_btn.click(
|
629 |
fn=execute_code,
|