seawolf2357 commited on
Commit
0bbb84d
·
verified ·
1 Parent(s): 16cc2de

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +12 -3
app.py CHANGED
@@ -62,9 +62,18 @@ def send_to_sandbox(code):
62
  data_uri = f"data:text/html;charset=utf-8;base64,{encoded_html}"
63
  return f"<iframe src=\"{data_uri}\" width=\"100%\" height=\"920px\"></iframe>"
64
 
 
 
 
 
65
  def demo_card_click(e: gr.EventData):
66
  index = e._data['component']['index']
67
- return DEMO_LIST[index]['description']
 
 
 
 
 
68
 
69
  with gr.Blocks(css_paths="app.css") as demo:
70
  history = gr.State([])
@@ -97,8 +106,8 @@ with gr.Blocks(css_paths="app.css") as demo:
97
  with ms.Each(DEMO_LIST):
98
  with antd.Card(hoverable=True, as_item="card") as demoCard:
99
  antd.CardMeta()
100
- demoCard.click(demo_card_click, outputs=[input], api_name="demo_click", cache=True)
101
-
102
  antd.Divider("setting")
103
 
104
  with antd.Flex(gap="small", wrap=True):
 
62
  data_uri = f"data:text/html;charset=utf-8;base64,{encoded_html}"
63
  return f"<iframe src=\"{data_uri}\" width=\"100%\" height=\"920px\"></iframe>"
64
 
65
+
66
+
67
+ DEMO_CACHE = {}
68
+
69
  def demo_card_click(e: gr.EventData):
70
  index = e._data['component']['index']
71
+ if index not in DEMO_CACHE:
72
+ DEMO_CACHE[index] = DEMO_LIST[index]['description']
73
+ return DEMO_CACHE[index]
74
+
75
+
76
+
77
 
78
  with gr.Blocks(css_paths="app.css") as demo:
79
  history = gr.State([])
 
106
  with ms.Each(DEMO_LIST):
107
  with antd.Card(hoverable=True, as_item="card") as demoCard:
108
  antd.CardMeta()
109
+ demoCard.click(demo_card_click, outputs=[input])
110
+
111
  antd.Divider("setting")
112
 
113
  with antd.Flex(gap="small", wrap=True):