Spaces:
Paused
Paused
Update app.py
Browse files
app.py
CHANGED
|
@@ -756,21 +756,18 @@ with gr.Blocks(css_paths="app.css",theme=theme) as demo:
|
|
| 756 |
placeholder=random.choice(DEMO_LIST)['description']
|
| 757 |
)
|
| 758 |
|
| 759 |
-
# ๋ฒํผ๋ค์ ๊ฐ๋ก๋ก ๋ฐฐ์นํ๊ธฐ ์ํ Flex
|
| 760 |
-
with antd.Flex(vertical=True, gap="middle"):
|
| 761 |
with antd.Flex(gap="small", justify="space-between"):
|
| 762 |
btn = antd.Button("Send", type="primary", size="large")
|
| 763 |
execute_btn = antd.Button("Code ์คํ", type="default", size="large")
|
| 764 |
clear_btn = antd.Button("Clear", type="default", size="large")
|
| 765 |
|
| 766 |
-
|
| 767 |
with antd.Flex(gap="small", justify="space-between"):
|
| 768 |
best_btn = antd.Button("๐ ๋ฒ ์คํธ ํ
ํ๋ฆฟ", type="default", size="large")
|
| 769 |
trending_btn = antd.Button("๐ฅ ํธ๋ ๋ฉ ํ
ํ๋ฆฟ", type="default", size="large")
|
| 770 |
new_btn = antd.Button("โจ NEW ํ
ํ๋ฆฟ", type="default", size="large")
|
| 771 |
-
|
| 772 |
-
|
| 773 |
-
|
| 774 |
|
| 775 |
# ์ฐ์ธก ํจ๋
|
| 776 |
with antd.Col(span=24, md=16):
|
|
@@ -789,6 +786,25 @@ with gr.Blocks(css_paths="app.css",theme=theme) as demo:
|
|
| 789 |
with antd.Tabs.Item(key="render"):
|
| 790 |
sandbox = gr.HTML(elem_classes="html_content")
|
| 791 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 792 |
# ์ด๋ฒคํธ ํธ๋ค๋ฌ๋ค
|
| 793 |
execute_btn.click(
|
| 794 |
fn=execute_code,
|
|
|
|
| 756 |
placeholder=random.choice(DEMO_LIST)['description']
|
| 757 |
)
|
| 758 |
|
| 759 |
+
# ๋ฒํผ๋ค์ ๊ฐ๋ก๋ก ๋ฐฐ์นํ๊ธฐ ์ํ Flex ์ปจํ
์ด๋
|
| 760 |
+
with antd.Flex(vertical=True, gap="middle"):
|
| 761 |
with antd.Flex(gap="small", justify="space-between"):
|
| 762 |
btn = antd.Button("Send", type="primary", size="large")
|
| 763 |
execute_btn = antd.Button("Code ์คํ", type="default", size="large")
|
| 764 |
clear_btn = antd.Button("Clear", type="default", size="large")
|
| 765 |
|
| 766 |
+
# ํ
ํ๋ฆฟ ๋ฒํผ๋ค์ ์ํ ์๋ก์ด Flex ์ปจํ
์ด๋
|
| 767 |
with antd.Flex(gap="small", justify="space-between"):
|
| 768 |
best_btn = antd.Button("๐ ๋ฒ ์คํธ ํ
ํ๋ฆฟ", type="default", size="large")
|
| 769 |
trending_btn = antd.Button("๐ฅ ํธ๋ ๋ฉ ํ
ํ๋ฆฟ", type="default", size="large")
|
| 770 |
new_btn = antd.Button("โจ NEW ํ
ํ๋ฆฟ", type="default", size="large")
|
|
|
|
|
|
|
|
|
|
| 771 |
|
| 772 |
# ์ฐ์ธก ํจ๋
|
| 773 |
with antd.Col(span=24, md=16):
|
|
|
|
| 786 |
with antd.Tabs.Item(key="render"):
|
| 787 |
sandbox = gr.HTML(elem_classes="html_content")
|
| 788 |
|
| 789 |
+
# Code ์คํ ๋ฒํผ ์ด๋ฒคํธ ํธ๋ค๋ฌ ํจ์ ์ ์
|
| 790 |
+
def execute_code(query: str):
|
| 791 |
+
if not query or query.strip() == '':
|
| 792 |
+
return None, gr.update(active_key="empty")
|
| 793 |
+
|
| 794 |
+
try:
|
| 795 |
+
# HTML ์ฝ๋ ๋ธ๋ก ํ์ธ
|
| 796 |
+
if '```html' in query and '```' in query:
|
| 797 |
+
# HTML ์ฝ๋ ๋ธ๋ก ์ถ์ถ
|
| 798 |
+
code = remove_code_block(query)
|
| 799 |
+
else:
|
| 800 |
+
# ์
๋ ฅ๋ ํ
์คํธ๋ฅผ ๊ทธ๋๋ก ์ฝ๋๋ก ์ฌ์ฉ
|
| 801 |
+
code = query.strip()
|
| 802 |
+
|
| 803 |
+
return send_to_sandbox(code), gr.update(active_key="render")
|
| 804 |
+
except Exception as e:
|
| 805 |
+
print(f"Error executing code: {str(e)}")
|
| 806 |
+
return None, gr.update(active_key="empty")
|
| 807 |
+
|
| 808 |
# ์ด๋ฒคํธ ํธ๋ค๋ฌ๋ค
|
| 809 |
execute_btn.click(
|
| 810 |
fn=execute_code,
|