openfree commited on
Commit
09f2264
β€’
1 Parent(s): 9ffe47e

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +50 -3
app.py CHANGED
@@ -120,8 +120,55 @@ def get_trending_spaces(progress=gr.Progress()) -> Tuple[str, str]:
120
  """
121
 
122
  for idx, space in enumerate(top_spaces):
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
123
  progress((0.1 + 0.9 * idx/10), desc=f"Loading space {idx+1}/10...")
124
- html_content += get_space_card(space, idx)
125
 
126
  html_content += "</div></div>"
127
 
@@ -135,8 +182,8 @@ def get_trending_spaces(progress=gr.Progress()) -> Tuple[str, str]:
135
  def create_interface():
136
  """Gradio μΈν„°νŽ˜μ΄μŠ€ 생성"""
137
  with gr.Blocks(title="Hugging Face Trending Spaces") as interface:
138
- gr.Markdown("# πŸ€— Hugging Face Trending Spaces")
139
- gr.Markdown("Shows top 10 trending spaces on Hugging Face")
140
 
141
  with gr.Row():
142
  refresh_btn = gr.Button("Refresh Gallery", variant="primary")
 
120
  """
121
 
122
  for idx, space in enumerate(top_spaces):
123
+ author, title = space['id'].split('/', 1)
124
+ space_url = f"https://huggingface.co/spaces/{space['id']}"
125
+ likes = format(space.get('likes', 0), ',')
126
+ created = space.get('createdAt', '').split('T')[0]
127
+
128
+ screenshot = get_cached_screenshot(space_url)
129
+ bg_color = f"rgba({random.randint(230,255)}, {random.randint(230,255)}, {random.randint(230,255)}, 0.8)"
130
+
131
+ html_content += f"""
132
+ <div class="space-card" style='
133
+ position: relative;
134
+ border: none;
135
+ padding: 20px;
136
+ margin: 10px;
137
+ border-radius: 15px;
138
+ box-shadow: 0 4px 8px rgba(0,0,0,0.1);
139
+ background-image: linear-gradient({bg_color}, {bg_color}),
140
+ url(data:image/png;base64,{screenshot if screenshot else ''});
141
+ background-size: cover;
142
+ background-position: center;
143
+ background-blend-mode: overlay;
144
+ transition: transform 0.3s ease;
145
+ min-height: 250px;
146
+ cursor: pointer;'
147
+ onclick="window.open('{space_url}', '_blank')">
148
+
149
+ <div style='
150
+ position: absolute;
151
+ bottom: 0;
152
+ left: 0;
153
+ right: 0;
154
+ background: rgba(255, 255, 255, 0.95);
155
+ padding: 10px;
156
+ border-radius: 0 0 15px 15px;
157
+ font-size: 0.8em;'>
158
+ <div style='font-size: 1.2em; font-weight: bold; color: #333; margin-bottom: 5px;'>
159
+ #{idx + 1} {title}
160
+ </div>
161
+ <div style='display: grid; grid-template-columns: repeat(2, 1fr); gap: 5px;'>
162
+ <div style='color: #666;'>πŸ‘€ {author}</div>
163
+ <div style='color: #666;'>πŸ› οΈ {space.get('sdk', 'N/A')}</div>
164
+ <div style='color: #666;'>❀️ {likes}</div>
165
+ <div style='color: #666;'>πŸ“… {created}</div>
166
+ </div>
167
+ </div>
168
+ </div>
169
+ """
170
+
171
  progress((0.1 + 0.9 * idx/10), desc=f"Loading space {idx+1}/10...")
 
172
 
173
  html_content += "</div></div>"
174
 
 
182
  def create_interface():
183
  """Gradio μΈν„°νŽ˜μ΄μŠ€ 생성"""
184
  with gr.Blocks(title="Hugging Face Trending Spaces") as interface:
185
+ gr.Markdown("# πŸ€— Hugging Face Top 10 Trending Spaces")
186
+ gr.Markdown("Shows top 10 most liked spaces on Hugging Face")
187
 
188
  with gr.Row():
189
  refresh_btn = gr.Button("Refresh Gallery", variant="primary")