Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -111,7 +111,7 @@ df['url'] = 'https://huggingface.co/spaces/' + df['id']
|
|
111 |
|
112 |
# ------------------------------------------------------
|
113 |
|
114 |
-
def search_spaces(search_text, category):
|
115 |
if category == "All Categories":
|
116 |
spaces_df = df
|
117 |
else:
|
@@ -120,10 +120,10 @@ def search_spaces(search_text, category):
|
|
120 |
if search_text:
|
121 |
spaces_df = spaces_df[spaces_df['title'].str.lower().str.contains(search_text.lower())]
|
122 |
|
123 |
-
|
|
|
124 |
|
125 |
# Get category stats
|
126 |
-
total_spaces = len(spaces_df)
|
127 |
total_likes = spaces_df['likes'].sum()
|
128 |
|
129 |
# Format the results as HTML with clickable links and stats
|
@@ -138,7 +138,8 @@ def search_spaces(search_text, category):
|
|
138 |
<div style='display: grid; grid-template-columns: repeat(3, 1fr); gap: 15px; padding: 10px;'>
|
139 |
"""
|
140 |
|
141 |
-
|
|
|
142 |
html_content += f"""
|
143 |
<div style='padding: 15px;
|
144 |
border: 2px solid var(--color-border-primary);
|
|
|
111 |
|
112 |
# ------------------------------------------------------
|
113 |
|
114 |
+
def search_spaces(search_text="", category="All Categories", offset=0, page_size=30):
|
115 |
if category == "All Categories":
|
116 |
spaces_df = df
|
117 |
else:
|
|
|
120 |
if search_text:
|
121 |
spaces_df = spaces_df[spaces_df['title'].str.lower().str.contains(search_text.lower())]
|
122 |
|
123 |
+
total_spaces = len(spaces_df)
|
124 |
+
spaces = spaces_df.nlargest(offset + page_size, 'likes')[['title', 'likes', 'url', 'category']]
|
125 |
|
126 |
# Get category stats
|
|
|
127 |
total_likes = spaces_df['likes'].sum()
|
128 |
|
129 |
# Format the results as HTML with clickable links and stats
|
|
|
138 |
<div style='display: grid; grid-template-columns: repeat(3, 1fr); gap: 15px; padding: 10px;'>
|
139 |
"""
|
140 |
|
141 |
+
# Only show the spaces from offset to offset + page_size
|
142 |
+
for _, row in list(spaces.iterrows())[offset:offset + page_size]:
|
143 |
html_content += f"""
|
144 |
<div style='padding: 15px;
|
145 |
border: 2px solid var(--color-border-primary);
|