ginipick commited on
Commit
da191b4
·
verified ·
1 Parent(s): be1618e

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +22 -9
app.py CHANGED
@@ -94,17 +94,33 @@ def create_ui():
94
  formatted_spaces = format_spaces(spaces_list)
95
  print(f"Total spaces loaded: {len(formatted_spaces)}") # 디버깅 출력
96
 
97
- with gr.Blocks() as demo:
 
 
 
 
 
 
 
 
 
 
 
 
 
98
  gr.Markdown("# Hugging Face Most Liked Spaces")
99
 
100
  with gr.Row():
101
  with gr.Column(scale=1):
102
- space_buttons = []
103
  for space in formatted_spaces:
104
- with gr.Row():
105
- gr.Markdown(f"{space['name']} by {space['author']} (Likes: {space['likes']})")
106
- button = gr.Button("클릭", elem_id=f"btn-{space['id']}")
107
- space_buttons.append(button)
 
 
 
 
108
 
109
  with gr.Column(scale=1):
110
  info_output = gr.Textbox(label="Space 정보 및 요약", lines=10)
@@ -125,9 +141,6 @@ def create_ui():
125
  print(traceback.format_exc())
126
  return f"오류가 발생했습니다: {str(e)}", ""
127
 
128
- for button, space in zip(space_buttons, formatted_spaces):
129
- button.click(on_select, inputs=[gr.State(space)], outputs=[info_output, app_py_content])
130
-
131
  return demo
132
 
133
  if __name__ == "__main__":
 
94
  formatted_spaces = format_spaces(spaces_list)
95
  print(f"Total spaces loaded: {len(formatted_spaces)}") # 디버깅 출력
96
 
97
+ css = """
98
+ .minimal-button {
99
+ min-width: 30px !important;
100
+ height: 25px !important;
101
+ line-height: 1 !important;
102
+ font-size: 12px !important;
103
+ padding: 2px 5px !important;
104
+ }
105
+ .space-row {
106
+ margin-bottom: 5px !important;
107
+ }
108
+ """
109
+
110
+ with gr.Blocks(css=css) as demo:
111
  gr.Markdown("# Hugging Face Most Liked Spaces")
112
 
113
  with gr.Row():
114
  with gr.Column(scale=1):
 
115
  for space in formatted_spaces:
116
+ with gr.Row(elem_classes="space-row"):
117
+ gr.Markdown(f"{space['name']} by {space['author']} (Likes: {space['likes']})", elem_classes="space-info")
118
+ button = gr.Button("클릭", elem_classes="minimal-button")
119
+ button.click(
120
+ lambda s=space: on_select(s),
121
+ inputs=[],
122
+ outputs=[info_output, app_py_content]
123
+ )
124
 
125
  with gr.Column(scale=1):
126
  info_output = gr.Textbox(label="Space 정보 및 요약", lines=10)
 
141
  print(traceback.format_exc())
142
  return f"오류가 발생했습니다: {str(e)}", ""
143
 
 
 
 
144
  return demo
145
 
146
  if __name__ == "__main__":