Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,32 +1,27 @@
|
|
| 1 |
from flask import Flask, render_template, request, jsonify
|
| 2 |
import requests
|
| 3 |
import os
|
| 4 |
-
import json
|
| 5 |
-
import time
|
| 6 |
|
| 7 |
app = Flask(__name__)
|
| 8 |
|
| 9 |
# Function to fetch trending spaces from Huggingface
|
| 10 |
def fetch_trending_spaces(limit=100):
|
| 11 |
try:
|
| 12 |
-
#
|
| 13 |
url = "https://huggingface.co/api/spaces"
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
"sort": "trending" # ๋จ์ํ trending ํ๋ผ๋ฏธํฐ๋ง ์ฌ์ฉ
|
| 17 |
-
}
|
| 18 |
-
response = requests.get(url, params=params, timeout=10)
|
| 19 |
|
| 20 |
if response.status_code == 200:
|
| 21 |
# None ๊ฐ์ด ์๋ ํญ๋ชฉ ํํฐ๋ง
|
| 22 |
spaces = response.json()
|
| 23 |
filtered_spaces = [space for space in spaces if space.get('owner') != 'None' and space.get('id', '').split('/', 1)[0] != 'None']
|
| 24 |
-
return filtered_spaces
|
| 25 |
else:
|
| 26 |
-
print(f"Error fetching
|
| 27 |
return []
|
| 28 |
except Exception as e:
|
| 29 |
-
print(f"Exception when fetching
|
| 30 |
return []
|
| 31 |
|
| 32 |
# Transform Huggingface URL to direct space URL
|
|
@@ -284,6 +279,20 @@ if __name__ == '__main__':
|
|
| 284 |
margin-left: 4px;
|
| 285 |
}
|
| 286 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 287 |
.grid-content {
|
| 288 |
flex: 1;
|
| 289 |
position: relative;
|
|
@@ -445,6 +454,12 @@ if __name__ == '__main__':
|
|
| 445 |
const gridItem = document.createElement('div');
|
| 446 |
gridItem.className = 'grid-item';
|
| 447 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 448 |
// Header with title and actions
|
| 449 |
const header = document.createElement('div');
|
| 450 |
header.className = 'grid-header';
|
|
|
|
| 1 |
from flask import Flask, render_template, request, jsonify
|
| 2 |
import requests
|
| 3 |
import os
|
|
|
|
|
|
|
| 4 |
|
| 5 |
app = Flask(__name__)
|
| 6 |
|
| 7 |
# Function to fetch trending spaces from Huggingface
|
| 8 |
def fetch_trending_spaces(limit=100):
|
| 9 |
try:
|
| 10 |
+
# ๊ฐ์ฅ ๋จ์ํ ๋ฐฉ์์ผ๋ก API ํธ์ถ (ํ๋ผ๋ฏธํฐ ์์ด)
|
| 11 |
url = "https://huggingface.co/api/spaces"
|
| 12 |
+
|
| 13 |
+
response = requests.get(url, timeout=10)
|
|
|
|
|
|
|
|
|
|
| 14 |
|
| 15 |
if response.status_code == 200:
|
| 16 |
# None ๊ฐ์ด ์๋ ํญ๋ชฉ ํํฐ๋ง
|
| 17 |
spaces = response.json()
|
| 18 |
filtered_spaces = [space for space in spaces if space.get('owner') != 'None' and space.get('id', '').split('/', 1)[0] != 'None']
|
| 19 |
+
return filtered_spaces[:limit]
|
| 20 |
else:
|
| 21 |
+
print(f"Error fetching spaces: {response.status_code}")
|
| 22 |
return []
|
| 23 |
except Exception as e:
|
| 24 |
+
print(f"Exception when fetching spaces: {e}")
|
| 25 |
return []
|
| 26 |
|
| 27 |
# Transform Huggingface URL to direct space URL
|
|
|
|
| 279 |
margin-left: 4px;
|
| 280 |
}
|
| 281 |
|
| 282 |
+
.rank-badge {
|
| 283 |
+
position: absolute;
|
| 284 |
+
top: 10px;
|
| 285 |
+
left: 10px;
|
| 286 |
+
background: rgba(0,0,0,0.7);
|
| 287 |
+
color: white;
|
| 288 |
+
padding: 5px 15px;
|
| 289 |
+
border-radius: 20px;
|
| 290 |
+
font-weight: bold;
|
| 291 |
+
font-size: 0.9em;
|
| 292 |
+
backdrop-filter: blur(5px);
|
| 293 |
+
z-index: 3;
|
| 294 |
+
}
|
| 295 |
+
|
| 296 |
.grid-content {
|
| 297 |
flex: 1;
|
| 298 |
position: relative;
|
|
|
|
| 454 |
const gridItem = document.createElement('div');
|
| 455 |
gridItem.className = 'grid-item';
|
| 456 |
|
| 457 |
+
// Rank badge
|
| 458 |
+
const rankBadge = document.createElement('div');
|
| 459 |
+
rankBadge.className = 'rank-badge';
|
| 460 |
+
rankBadge.textContent = `#${index + 1}`;
|
| 461 |
+
gridItem.appendChild(rankBadge);
|
| 462 |
+
|
| 463 |
// Header with title and actions
|
| 464 |
const header = document.createElement('div');
|
| 465 |
header.className = 'grid-header';
|