openfree commited on
Commit
de7bd5a
โ€ข
1 Parent(s): 189b3c1

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +19 -5
app.py CHANGED
@@ -1728,6 +1728,24 @@ def get_user_spaces():
1728
  def create_main_interface():
1729
  """๋ฉ”์ธ ์ธํ„ฐํŽ˜์ด์Šค ์ƒ์„ฑ ํ•จ์ˆ˜"""
1730
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1731
  with gr.Blocks(css="""
1732
  /* ๋ฉ”์ธ ํƒญ ์Šคํƒ€์ผ */
1733
  .main-tabs > div.tab-nav > button {
@@ -1963,8 +1981,4 @@ def create_main_interface():
1963
  outputs=[deploy_result]
1964
  )
1965
 
1966
- return demo
1967
-
1968
- if __name__ == "__main__":
1969
- demo = create_main_interface()
1970
- demo.queue(default_concurrency_limit=20).launch(ssr_mode=False)
 
1728
  def create_main_interface():
1729
  """๋ฉ”์ธ ์ธํ„ฐํŽ˜์ด์Šค ์ƒ์„ฑ ํ•จ์ˆ˜"""
1730
 
1731
+ def execute_code(query: str):
1732
+ if not query or query.strip() == '':
1733
+ return None, gr.update(active_key="empty")
1734
+
1735
+ try:
1736
+ # HTML ์ฝ”๋“œ ๋ธ”๋ก ํ™•์ธ
1737
+ if '```html' in query and '```' in query:
1738
+ # HTML ์ฝ”๋“œ ๋ธ”๋ก ์ถ”์ถœ
1739
+ code = remove_code_block(query)
1740
+ else:
1741
+ # ์ž…๋ ฅ๋œ ํ…์ŠคํŠธ๋ฅผ ๊ทธ๋Œ€๋กœ ์ฝ”๋“œ๋กœ ์‚ฌ์šฉ
1742
+ code = query.strip()
1743
+
1744
+ return send_to_sandbox(code), gr.update(active_key="render")
1745
+ except Exception as e:
1746
+ print(f"Error executing code: {str(e)}")
1747
+ return None, gr.update(active_key="empty")
1748
+
1749
  with gr.Blocks(css="""
1750
  /* ๋ฉ”์ธ ํƒญ ์Šคํƒ€์ผ */
1751
  .main-tabs > div.tab-nav > button {
 
1981
  outputs=[deploy_result]
1982
  )
1983
 
1984
+ return demo