Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -114,15 +114,15 @@ def create_ui():
|
|
114 |
with gr.Row():
|
115 |
with gr.Column(scale=1):
|
116 |
space_table = gr.HTML(create_table_html(formatted_spaces))
|
|
|
117 |
|
118 |
with gr.Column(scale=1):
|
119 |
info_output = gr.Textbox(label="Space ์ ๋ณด ๋ฐ ์์ฝ", lines=10)
|
120 |
app_py_content = gr.Code(language="python", label="app.py ๋ด์ฉ")
|
121 |
|
122 |
-
def on_select(
|
123 |
try:
|
124 |
-
|
125 |
-
selected_space = formatted_spaces[space_index]
|
126 |
summary = summarize_space(selected_space)
|
127 |
app_content = get_app_py_content(selected_space['id'])
|
128 |
info = f"์ ํ๋ Space: {selected_space['name']} (ID: {selected_space['id']})\n"
|
@@ -136,15 +136,18 @@ def create_ui():
|
|
136 |
print(traceback.format_exc())
|
137 |
return f"์ค๋ฅ๊ฐ ๋ฐ์ํ์ต๋๋ค: {str(e)}", ""
|
138 |
|
139 |
-
|
|
|
140 |
function selectSpace(index) {
|
141 |
document.querySelectorAll('button').forEach(btn => btn.classList.remove('selected'));
|
142 |
event.target.classList.add('selected');
|
143 |
-
|
144 |
}
|
145 |
-
"""
|
|
|
|
|
146 |
|
147 |
-
|
148 |
|
149 |
return demo
|
150 |
|
|
|
114 |
with gr.Row():
|
115 |
with gr.Column(scale=1):
|
116 |
space_table = gr.HTML(create_table_html(formatted_spaces))
|
117 |
+
selected_index = gr.State(-1)
|
118 |
|
119 |
with gr.Column(scale=1):
|
120 |
info_output = gr.Textbox(label="Space ์ ๋ณด ๋ฐ ์์ฝ", lines=10)
|
121 |
app_py_content = gr.Code(language="python", label="app.py ๋ด์ฉ")
|
122 |
|
123 |
+
def on_select(index):
|
124 |
try:
|
125 |
+
selected_space = formatted_spaces[index]
|
|
|
126 |
summary = summarize_space(selected_space)
|
127 |
app_content = get_app_py_content(selected_space['id'])
|
128 |
info = f"์ ํ๋ Space: {selected_space['name']} (ID: {selected_space['id']})\n"
|
|
|
136 |
print(traceback.format_exc())
|
137 |
return f"์ค๋ฅ๊ฐ ๋ฐ์ํ์ต๋๋ค: {str(e)}", ""
|
138 |
|
139 |
+
# JavaScript to handle button clicks
|
140 |
+
js_code = """
|
141 |
function selectSpace(index) {
|
142 |
document.querySelectorAll('button').forEach(btn => btn.classList.remove('selected'));
|
143 |
event.target.classList.add('selected');
|
144 |
+
selectedIndex.update(index);
|
145 |
}
|
146 |
+
"""
|
147 |
+
demo.load(None, None, None)
|
148 |
+
gr.HTML(f"<script>{js_code}</script>")
|
149 |
|
150 |
+
selected_index.change(on_select, inputs=[selected_index], outputs=[info_output, app_py_content])
|
151 |
|
152 |
return demo
|
153 |
|