ginipick commited on
Commit
120baa2
ยท
verified ยท
1 Parent(s): 5cfddce

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +9 -9
app.py CHANGED
@@ -117,7 +117,7 @@ def create_ui():
117
  with gr.Row():
118
  with gr.Column(scale=1):
119
  space_list = gr.List(
120
- [f"{space['name']} by {space['author']} (Likes: {space['likes']})" for space in formatted_spaces],
121
  label="Most Liked Spaces"
122
  )
123
  summarize_btn = gr.Button("์š”์•ฝ")
@@ -130,16 +130,16 @@ def create_ui():
130
  global selected_space_info
131
  try:
132
  print(f"Selection event: {evt}") # ๋””๋ฒ„๊น… ์ถœ๋ ฅ
133
- selected_index = evt.index
134
- if 0 <= selected_index < len(formatted_spaces):
135
- selected_space = formatted_spaces[selected_index]
136
  selected_space_info = selected_space
137
- app_content = get_app_py_content(selected_space['id'])
138
- print(f"Selected space: {selected_space['name']} (ID: {selected_space['id']})") # ๋””๋ฒ„๊น… ์ถœ๋ ฅ
139
- return f"์„ ํƒ๋œ Space: {selected_space['name']} (ID: {selected_space['id']})\nURL: {selected_space['url']}", app_content
140
  else:
141
- print(f"Invalid selection index: {selected_index}") # ๋””๋ฒ„๊น… ์ถœ๋ ฅ
142
- return "์ž˜๋ชป๋œ ์„ ํƒ์ž…๋‹ˆ๋‹ค.", ""
143
  except Exception as e:
144
  print(f"Error in on_select: {str(e)}")
145
  print(traceback.format_exc()) # ์ƒ์„ธํ•œ ์˜ค๋ฅ˜ ์ •๋ณด ์ถœ๋ ฅ
 
117
  with gr.Row():
118
  with gr.Column(scale=1):
119
  space_list = gr.List(
120
+ [(f"{space['name']} by {space['author']} (Likes: {space['likes']})", space['id']) for space in formatted_spaces],
121
  label="Most Liked Spaces"
122
  )
123
  summarize_btn = gr.Button("์š”์•ฝ")
 
130
  global selected_space_info
131
  try:
132
  print(f"Selection event: {evt}") # ๋””๋ฒ„๊น… ์ถœ๋ ฅ
133
+ selected_id = evt.value[1] # ํŠœํ”Œ์˜ ๋‘ ๋ฒˆ์งธ ์š”์†Œ๊ฐ€ space_id์ž…๋‹ˆ๋‹ค.
134
+ selected_space = next((space for space in formatted_spaces if space['id'] == selected_id), None)
135
+ if selected_space:
136
  selected_space_info = selected_space
137
+ app_content = get_app_py_content(selected_id)
138
+ print(f"Selected space: {selected_space['name']} (ID: {selected_id})") # ๋””๋ฒ„๊น… ์ถœ๋ ฅ
139
+ return f"์„ ํƒ๋œ Space: {selected_space['name']} (ID: {selected_id})\nURL: {selected_space['url']}", app_content
140
  else:
141
+ print(f"Space not found for ID: {selected_id}") # ๋””๋ฒ„๊น… ์ถœ๋ ฅ
142
+ return "์„ ํƒ๋œ space๋ฅผ ์ฐพ์„ ์ˆ˜ ์—†์Šต๋‹ˆ๋‹ค.", ""
143
  except Exception as e:
144
  print(f"Error in on_select: {str(e)}")
145
  print(traceback.format_exc()) # ์ƒ์„ธํ•œ ์˜ค๋ฅ˜ ์ •๋ณด ์ถœ๋ ฅ