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

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +124 -123
app.py CHANGED
@@ -911,18 +911,6 @@ def handle_boost(prompt: str):
911
  demo_instance = Demo()
912
 
913
 
914
-
915
-
916
-
917
-
918
-
919
-
920
-
921
-
922
-
923
-
924
-
925
-
926
  def take_screenshot(url):
927
  """์›น์‚ฌ์ดํŠธ ์Šคํฌ๋ฆฐ์ƒท ์ดฌ์˜ ํ•จ์ˆ˜ (๋กœ๋”ฉ ๋Œ€๊ธฐ ์‹œ๊ฐ„ ์ถ”๊ฐ€)"""
928
  if not url.startswith('http'):
@@ -1741,6 +1729,7 @@ def create_main_interface():
1741
  """๋ฉ”์ธ ์ธํ„ฐํŽ˜์ด์Šค ์ƒ์„ฑ ํ•จ์ˆ˜"""
1742
 
1743
  with gr.Blocks(css="""
 
1744
  .main-tabs > div.tab-nav > button {
1745
  font-size: 1.1em !important;
1746
  padding: 0.5em 1em !important;
@@ -1758,6 +1747,41 @@ def create_main_interface():
1758
  border-radius: 0 0 15px 15px !important;
1759
  box-shadow: 0 4px 15px rgba(0,0,0,0.1) !important;
1760
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1761
  """, theme=theme) as demo:
1762
  with gr.Tabs(elem_classes="main-tabs") as tabs:
1763
  # ๊ฐค๋Ÿฌ๋ฆฌ ํƒญ
@@ -1808,7 +1832,12 @@ def create_main_interface():
1808
  <div class="left_header">
1809
  <img src="data:image/gif;base64,{get_image_base64('mouse.gif')}" width="360px" />
1810
  <h1 style="font-size: 18px;">๊ณ ์–‘์ด๋„ ๋ฐœ๋กœ ์ฝ”๋”ฉํ•˜๋Š” 'MOUSE-I'</h2>
1811
- <h1 style="font-size: 10px;">ํ…œํ”Œ๋ฆฟ์˜ ํ”„๋กฌํ”„ํŠธ๋ฅผ ๋ณต์‚ฌํ•˜์—ฌ ๋ถ™์—ฌ๋„ฃ๊ณ  Send ํด๋ฆญ์‹œ ์ž๋™์œผ๋กœ ์ฝ”๋“œ๊ฐ€ ์ƒ์„ฑ๋ฉ๋‹ˆ๋‹ค...</h1>
 
 
 
 
 
1812
  </div>
1813
  """)
1814
 
@@ -1851,116 +1880,88 @@ def create_main_interface():
1851
  with antd.Tabs.Item(key="render"):
1852
  sandbox = gr.HTML(elem_classes="html_content")
1853
 
1854
-
1855
-
1856
-
1857
- # Code ์‹คํ–‰ ๋ฒ„ํŠผ ์ด๋ฒคํŠธ ํ•ธ๋“ค๋Ÿฌ ํ•จ์ˆ˜ ์ •์˜
1858
- def execute_code(query: str):
1859
- if not query or query.strip() == '':
1860
- return None, gr.update(active_key="empty")
1861
-
1862
- try:
1863
- # HTML ์ฝ”๋“œ ๋ธ”๋ก ํ™•์ธ
1864
- if '```html' in query and '```' in query:
1865
- # HTML ์ฝ”๋“œ ๋ธ”๋ก ์ถ”์ถœ
1866
- code = remove_code_block(query)
1867
- else:
1868
- # ์ž…๋ ฅ๋œ ํ…์ŠคํŠธ๋ฅผ ๊ทธ๋Œ€๋กœ ์ฝ”๋“œ๋กœ ์‚ฌ์šฉ
1869
- code = query.strip()
1870
-
1871
- return send_to_sandbox(code), gr.update(active_key="render")
1872
- except Exception as e:
1873
- print(f"Error executing code: {str(e)}")
1874
- return None, gr.update(active_key="empty")
1875
-
1876
- # ์ด๋ฒคํŠธ ํ•ธ๋“ค๋Ÿฌ๋“ค
1877
- execute_btn.click(
1878
- fn=execute_code,
1879
- inputs=[input],
1880
- outputs=[sandbox, state_tab]
1881
- )
1882
-
1883
- codeBtn.click(
1884
- lambda: gr.update(open=True),
1885
- inputs=[],
1886
- outputs=[code_drawer]
1887
- )
1888
-
1889
- code_drawer.close(
1890
- lambda: gr.update(open=False),
1891
- inputs=[],
1892
- outputs=[code_drawer]
1893
- )
1894
-
1895
- historyBtn.click(
1896
- history_render,
1897
- inputs=[history],
1898
- outputs=[history_drawer, history_output]
1899
- )
1900
-
1901
- history_drawer.close(
1902
- lambda: gr.update(open=False),
1903
- inputs=[],
1904
- outputs=[history_drawer]
1905
- )
1906
-
1907
- # ํ…œํ”Œ๋ฆฟ ๋ฒ„ํŠผ ์ด๋ฒคํŠธ ํ•ธ๋“ค๋Ÿฌ
1908
- best_btn.click(
1909
- fn=lambda: (gr.update(open=True), load_best_templates()),
1910
- outputs=[session_drawer, session_history],
1911
- queue=False
1912
- )
1913
-
1914
- trending_btn.click(
1915
- fn=lambda: (gr.update(open=True), load_trending_templates()),
1916
- outputs=[session_drawer, session_history],
1917
- queue=False
1918
- )
1919
-
1920
- new_btn.click(
1921
- fn=lambda: (gr.update(open=True), load_new_templates()),
1922
- outputs=[session_drawer, session_history],
1923
- queue=False
1924
- )
1925
-
1926
- session_drawer.close(
1927
- lambda: (gr.update(open=False), gr.HTML("")),
1928
- outputs=[session_drawer, session_history]
1929
- )
1930
-
1931
- close_btn.click(
1932
- lambda: (gr.update(open=False), gr.HTML("")),
1933
- outputs=[session_drawer, session_history]
1934
- )
1935
-
1936
- btn.click(
1937
- demo_instance.generation_code,
1938
- inputs=[input, setting, history],
1939
- outputs=[code_output, history, sandbox, state_tab, code_drawer]
1940
- )
1941
-
1942
- clear_btn.click(
1943
- demo_instance.clear_history,
1944
- inputs=[],
1945
- outputs=[history]
1946
- )
1947
-
1948
- # UI์˜ Boost ๋ฒ„ํŠผ ์ด๋ฒคํŠธ ์—ฐ๊ฒฐ ์ˆ˜์ •
1949
- boost_btn.click(
1950
- fn=handle_boost,
1951
- inputs=[input],
1952
- outputs=[input, state_tab]
1953
- )
1954
-
1955
-
1956
-
1957
- # ์ด๋ฒคํŠธ ํ•ธ๋“ค๋Ÿฌ ์ˆ˜์ •
1958
- deploy_btn.click(
1959
- fn=lambda code: deploy_to_vercel(remove_code_block(code)) if code else "์ฝ”๋“œ๊ฐ€ ์—†์Šต๋‹ˆ๋‹ค.",
1960
- inputs=[code_output],
1961
- outputs=[deploy_result]
1962
- )
1963
-
1964
 
1965
  return demo
1966
 
 
911
  demo_instance = Demo()
912
 
913
 
 
 
 
 
 
 
 
 
 
 
 
 
914
  def take_screenshot(url):
915
  """์›น์‚ฌ์ดํŠธ ์Šคํฌ๋ฆฐ์ƒท ์ดฌ์˜ ํ•จ์ˆ˜ (๋กœ๋”ฉ ๋Œ€๊ธฐ ์‹œ๊ฐ„ ์ถ”๊ฐ€)"""
916
  if not url.startswith('http'):
 
1729
  """๋ฉ”์ธ ์ธํ„ฐํŽ˜์ด์Šค ์ƒ์„ฑ ํ•จ์ˆ˜"""
1730
 
1731
  with gr.Blocks(css="""
1732
+ /* ๋ฉ”์ธ ํƒญ ์Šคํƒ€์ผ */
1733
  .main-tabs > div.tab-nav > button {
1734
  font-size: 1.1em !important;
1735
  padding: 0.5em 1em !important;
 
1747
  border-radius: 0 0 15px 15px !important;
1748
  box-shadow: 0 4px 15px rgba(0,0,0,0.1) !important;
1749
  }
1750
+
1751
+ /* MOUSE ์ธํ„ฐํŽ˜์ด์Šค ์Šคํƒ€์ผ */
1752
+ .left_header {
1753
+ text-align: center;
1754
+ margin-bottom: 20px;
1755
+ }
1756
+ .right_panel {
1757
+ background: white;
1758
+ border-radius: 15px;
1759
+ padding: 20px;
1760
+ box-shadow: 0 4px 15px rgba(0,0,0,0.1);
1761
+ }
1762
+ .setting-buttons {
1763
+ margin-bottom: 15px;
1764
+ }
1765
+ .render_header {
1766
+ background: #f5f5f5;
1767
+ padding: 10px;
1768
+ border-radius: 8px;
1769
+ margin-bottom: 15px;
1770
+ }
1771
+ .header_btn {
1772
+ display: inline-block;
1773
+ width: 12px;
1774
+ height: 12px;
1775
+ border-radius: 50%;
1776
+ margin-right: 8px;
1777
+ background: #ddd;
1778
+ }
1779
+ .html_content {
1780
+ min-height: 500px;
1781
+ border: 1px solid #eee;
1782
+ border-radius: 8px;
1783
+ overflow: hidden;
1784
+ }
1785
  """, theme=theme) as demo:
1786
  with gr.Tabs(elem_classes="main-tabs") as tabs:
1787
  # ๊ฐค๋Ÿฌ๋ฆฌ ํƒญ
 
1832
  <div class="left_header">
1833
  <img src="data:image/gif;base64,{get_image_base64('mouse.gif')}" width="360px" />
1834
  <h1 style="font-size: 18px;">๊ณ ์–‘์ด๋„ ๋ฐœ๋กœ ์ฝ”๋”ฉํ•˜๋Š” 'MOUSE-I'</h2>
1835
+ <h1 style="font-size: 10px;">ํ…œํ”Œ๋ฆฟ์˜ ํ”„๋กฌํ”„ํŠธ๋ฅผ ๋ณต์‚ฌํ•˜์—ฌ ๋ถ™์—ฌ๋„ฃ๊ณ  Send ํด๋ฆญ์‹œ ์ž๋™์œผ๋กœ ์ฝ”๋“œ๊ฐ€ ์ƒ์„ฑ๋ฉ๋‹ˆ๋‹ค. ์ƒ์„ฑ ๊ฒฐ๊ณผ๋ฅผ ํ™•์ธ ๋ฐฐํฌํ•˜๊ธฐ ํด๋ฆญ์‹œ ๊ธ€๋กœ๋ฒŒ ํฌ๋ผ์šฐ๋“œ Vercel์„ ํ†ตํ•ด ์›น์„œ๋น„์Šค๊ฐ€ ๋ฐฐํฌ๋ฉ๋‹ˆ๋‹ค. ์ƒ์„ฑ๋œ ์ฝ”๋“œ๋งŒ ํ”„๋กฌํ”„ํŠธ์— ๋ถ™์—ฌ๋„ฃ๊ณ  'Code ์‹คํ–‰' ๋ฒ„ํŠผ ํด๋ฆญ์‹œ ํ™”๋ฉด์— ์ฆ‰์‹œ ์„œ๋น„์Šค๊ฐ€ ์‹คํ–‰. ๋ฌธ์˜: arxivgpt@gmail.com</h1>
1836
+ <h1 style="font-size: 12px; margin-top: 10px;">
1837
+ <a href="https://openfree-gallery.hf.space" target="_blank" style="color: #0084ff; text-decoration: none; transition: color 0.3s;">
1838
+ ๐ŸŽจ MOUSE๋กœ ์ƒ์„ฑํ•œ ์›น์•ฑ ๊ณต๊ฐœ ๊ฐค๋Ÿฌ๋ฆฌ ๋ฐ”๋กœ๊ฐ€๊ธฐ ํด๋ฆญ
1839
+ </a>
1840
+ </h1>
1841
  </div>
1842
  """)
1843
 
 
1880
  with antd.Tabs.Item(key="render"):
1881
  sandbox = gr.HTML(elem_classes="html_content")
1882
 
1883
+ # ์ด๋ฒคํŠธ ํ•ธ๋“ค๋Ÿฌ ์—ฐ๊ฒฐ
1884
+ execute_btn.click(
1885
+ fn=execute_code,
1886
+ inputs=[input],
1887
+ outputs=[sandbox, state_tab]
1888
+ )
1889
+
1890
+ codeBtn.click(
1891
+ lambda: gr.update(open=True),
1892
+ inputs=[],
1893
+ outputs=[code_drawer]
1894
+ )
1895
+
1896
+ code_drawer.close(
1897
+ lambda: gr.update(open=False),
1898
+ inputs=[],
1899
+ outputs=[code_drawer]
1900
+ )
1901
+
1902
+ historyBtn.click(
1903
+ history_render,
1904
+ inputs=[history],
1905
+ outputs=[history_drawer, history_output]
1906
+ )
1907
+
1908
+ history_drawer.close(
1909
+ lambda: gr.update(open=False),
1910
+ inputs=[],
1911
+ outputs=[history_drawer]
1912
+ )
1913
+
1914
+ best_btn.click(
1915
+ fn=lambda: (gr.update(open=True), load_best_templates()),
1916
+ outputs=[session_drawer, session_history],
1917
+ queue=False
1918
+ )
1919
+
1920
+ trending_btn.click(
1921
+ fn=lambda: (gr.update(open=True), load_trending_templates()),
1922
+ outputs=[session_drawer, session_history],
1923
+ queue=False
1924
+ )
1925
+
1926
+ new_btn.click(
1927
+ fn=lambda: (gr.update(open=True), load_new_templates()),
1928
+ outputs=[session_drawer, session_history],
1929
+ queue=False
1930
+ )
1931
+
1932
+ session_drawer.close(
1933
+ lambda: (gr.update(open=False), gr.HTML("")),
1934
+ outputs=[session_drawer, session_history]
1935
+ )
1936
+
1937
+ close_btn.click(
1938
+ lambda: (gr.update(open=False), gr.HTML("")),
1939
+ outputs=[session_drawer, session_history]
1940
+ )
1941
+
1942
+ btn.click(
1943
+ demo_instance.generation_code,
1944
+ inputs=[input, setting, history],
1945
+ outputs=[code_output, history, sandbox, state_tab, code_drawer]
1946
+ )
1947
+
1948
+ clear_btn.click(
1949
+ demo_instance.clear_history,
1950
+ inputs=[],
1951
+ outputs=[history]
1952
+ )
1953
+
1954
+ boost_btn.click(
1955
+ fn=handle_boost,
1956
+ inputs=[input],
1957
+ outputs=[input, state_tab]
1958
+ )
1959
+
1960
+ deploy_btn.click(
1961
+ fn=lambda code: deploy_to_vercel(remove_code_block(code)) if code else "์ฝ”๋“œ๊ฐ€ ์—†์Šต๋‹ˆ๋‹ค.",
1962
+ inputs=[code_output],
1963
+ outputs=[deploy_result]
1964
+ )
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1965
 
1966
  return demo
1967