Spaces:
Paused
Paused
Update app.py
Browse files
app.py
CHANGED
|
@@ -193,50 +193,35 @@ def get_space_card(space, index):
|
|
| 193 |
"""
|
| 194 |
|
| 195 |
def get_vercel_deployments():
|
| 196 |
-
"""Vercel API๋ฅผ ํตํด ๋ฐฐํฌ๋ ์๋น์ค ์ ๋ณด ๊ฐ์ ธ์ค๊ธฐ
|
| 197 |
token = "A8IFZmgW2cqA4yUNlLPnci0N"
|
| 198 |
-
|
| 199 |
|
| 200 |
headers = {
|
| 201 |
"Authorization": f"Bearer {token}",
|
| 202 |
"Content-Type": "application/json"
|
| 203 |
}
|
| 204 |
|
| 205 |
-
all_deployments = []
|
| 206 |
-
next_page = None
|
| 207 |
-
|
| 208 |
try:
|
| 209 |
-
|
| 210 |
-
|
| 211 |
-
|
| 212 |
-
|
| 213 |
-
|
| 214 |
-
|
| 215 |
-
|
| 216 |
-
break
|
| 217 |
-
|
| 218 |
-
data = response.json()
|
| 219 |
-
deployments = data.get('deployments', [])
|
| 220 |
-
all_deployments.extend(deployments)
|
| 221 |
-
|
| 222 |
-
# ๋ค์ ํ์ด์ง URL ํ์ธ
|
| 223 |
-
pagination = data.get('pagination', {})
|
| 224 |
-
next_page = pagination.get('next')
|
| 225 |
|
| 226 |
-
|
| 227 |
-
if not next_page:
|
| 228 |
-
break
|
| 229 |
|
| 230 |
# ์ํ๊ฐ 'READY'์ด๊ณ 'url'์ด ์๋ ๋ฐฐํฌ๋ง ํํฐ๋งํ๊ณ 'javis1' ์ ์ธ
|
| 231 |
active_deployments = [
|
| 232 |
-
dep for dep in
|
| 233 |
if dep.get('state') == 'READY' and
|
| 234 |
dep.get('url') and
|
| 235 |
'javis1' not in dep.get('name', '').lower()
|
| 236 |
]
|
| 237 |
|
| 238 |
return active_deployments
|
| 239 |
-
|
| 240 |
except Exception as e:
|
| 241 |
print(f"Error fetching Vercel deployments: {str(e)}")
|
| 242 |
return []
|
|
@@ -553,11 +538,13 @@ def get_user_spaces():
|
|
| 553 |
if not should_exclude_space(space.get('id', '').split('/')[-1])
|
| 554 |
]
|
| 555 |
|
| 556 |
-
#
|
| 557 |
-
|
| 558 |
|
| 559 |
-
#
|
| 560 |
-
|
|
|
|
|
|
|
| 561 |
|
| 562 |
html_content = f"""
|
| 563 |
<div style='padding: 20px; background-color: #f5f5f5;'>
|
|
@@ -571,12 +558,11 @@ def get_user_spaces():
|
|
| 571 |
</a>
|
| 572 |
</p>
|
| 573 |
<p style='color: #666; margin: 0;'>
|
| 574 |
-
Found {
|
|
|
|
| 575 |
</p>
|
| 576 |
</div>
|
| 577 |
|
| 578 |
-
|
| 579 |
-
|
| 580 |
<!-- Top Best -->
|
| 581 |
<h3 style='color: #333; margin: 20px 0;'>๐ Top Best</h3>
|
| 582 |
<div style='display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 20px;'>
|
|
@@ -585,10 +571,12 @@ def get_user_spaces():
|
|
| 585 |
</div>
|
| 586 |
|
| 587 |
<!-- Vercel Deployments -->
|
|
|
|
| 588 |
<h3 style='color: #333; margin: 20px 0;'>โก Vercel Deployments</h3>
|
| 589 |
<div id="vercel-container" style='display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 20px;'>
|
| 590 |
{"".join(get_vercel_card(dep, idx) for idx, dep in enumerate(vercel_deployments))}
|
| 591 |
</div>
|
|
|
|
| 592 |
|
| 593 |
<!-- Hugging Face Spaces -->
|
| 594 |
<h3 style='color: #333; margin: 20px 0;'>๐ค Hugging Face Spaces</h3>
|
|
@@ -598,59 +586,9 @@ def get_user_spaces():
|
|
| 598 |
</div>
|
| 599 |
|
| 600 |
<script>
|
| 601 |
-
|
| 602 |
-
// ์ข์์ ์ํ ๋ก๋
|
| 603 |
-
function loadLikes() {{
|
| 604 |
-
const cards = document.querySelectorAll('.vercel-card');
|
| 605 |
-
cards.forEach(card => {{
|
| 606 |
-
const cardId = card.id;
|
| 607 |
-
const likes = localStorage.getItem(cardId) || 0;
|
| 608 |
-
card.querySelector('.like-count').textContent = likes;
|
| 609 |
-
card.dataset.likes = likes;
|
| 610 |
-
updateLikeButton(card, likes > 0);
|
| 611 |
-
}});
|
| 612 |
-
sortCards();
|
| 613 |
-
}}
|
| 614 |
-
|
| 615 |
-
// ์ข์์ ๋ฒํผ ํ ๊ธ
|
| 616 |
-
window.toggleLike = function(cardId) {{
|
| 617 |
-
const card = document.getElementById(cardId);
|
| 618 |
-
const likeCount = parseInt(localStorage.getItem(cardId) || 0);
|
| 619 |
-
const newCount = likeCount > 0 ? 0 : 1;
|
| 620 |
-
|
| 621 |
-
localStorage.setItem(cardId, newCount);
|
| 622 |
-
card.querySelector('.like-count').textContent = newCount;
|
| 623 |
-
card.dataset.likes = newCount;
|
| 624 |
-
updateLikeButton(card, newCount > 0);
|
| 625 |
-
|
| 626 |
-
sortCards();
|
| 627 |
-
}}
|
| 628 |
-
|
| 629 |
-
// ์ข์์ ๋ฒํผ ์ํ ์
๋ฐ์ดํธ
|
| 630 |
-
function updateLikeButton(card, isLiked) {{
|
| 631 |
-
const button = card.querySelector('.like-button');
|
| 632 |
-
button.textContent = isLiked ? 'โค๏ธ' : '๐ค';
|
| 633 |
-
}}
|
| 634 |
-
|
| 635 |
-
// ์นด๋ ์ ๋ ฌ
|
| 636 |
-
function sortCards() {{
|
| 637 |
-
const container = document.getElementById('vercel-container');
|
| 638 |
-
const cards = Array.from(container.children);
|
| 639 |
-
|
| 640 |
-
cards.sort((a, b) => {{
|
| 641 |
-
return parseInt(b.dataset.likes) - parseInt(a.dataset.likes);
|
| 642 |
-
}});
|
| 643 |
-
|
| 644 |
-
cards.forEach(card => container.appendChild(card));
|
| 645 |
-
}}
|
| 646 |
-
|
| 647 |
-
// ์ด๊ธฐ ๋ก๋
|
| 648 |
-
loadLikes();
|
| 649 |
-
}});
|
| 650 |
</script>
|
| 651 |
"""
|
| 652 |
-
|
| 653 |
-
|
| 654 |
return html_content
|
| 655 |
|
| 656 |
except Exception as e:
|
|
|
|
| 193 |
"""
|
| 194 |
|
| 195 |
def get_vercel_deployments():
|
| 196 |
+
"""Vercel API๋ฅผ ํตํด ๋ฐฐํฌ๋ ์๋น์ค ์ ๋ณด ๊ฐ์ ธ์ค๊ธฐ"""
|
| 197 |
token = "A8IFZmgW2cqA4yUNlLPnci0N"
|
| 198 |
+
url = "https://api.vercel.com/v6/deployments?limit=100"
|
| 199 |
|
| 200 |
headers = {
|
| 201 |
"Authorization": f"Bearer {token}",
|
| 202 |
"Content-Type": "application/json"
|
| 203 |
}
|
| 204 |
|
|
|
|
|
|
|
|
|
|
| 205 |
try:
|
| 206 |
+
response = requests.get(url, headers=headers)
|
| 207 |
+
print(f"Debug - Vercel API status code: {response.status_code}") # ๋๋ฒ๊น
๋ก๊ทธ
|
| 208 |
+
print(f"Debug - Vercel API response: {response.text[:500]}") # ์๋ต ๋ด์ฉ ์ผ๋ถ ์ถ๋ ฅ
|
| 209 |
+
|
| 210 |
+
if response.status_code != 200:
|
| 211 |
+
print(f"Vercel API Error: {response.text}")
|
| 212 |
+
return []
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 213 |
|
| 214 |
+
deployments = response.json().get('deployments', [])
|
|
|
|
|
|
|
| 215 |
|
| 216 |
# ์ํ๊ฐ 'READY'์ด๊ณ 'url'์ด ์๋ ๋ฐฐํฌ๋ง ํํฐ๋งํ๊ณ 'javis1' ์ ์ธ
|
| 217 |
active_deployments = [
|
| 218 |
+
dep for dep in deployments
|
| 219 |
if dep.get('state') == 'READY' and
|
| 220 |
dep.get('url') and
|
| 221 |
'javis1' not in dep.get('name', '').lower()
|
| 222 |
]
|
| 223 |
|
| 224 |
return active_deployments
|
|
|
|
| 225 |
except Exception as e:
|
| 226 |
print(f"Error fetching Vercel deployments: {str(e)}")
|
| 227 |
return []
|
|
|
|
| 538 |
if not should_exclude_space(space.get('id', '').split('/')[-1])
|
| 539 |
]
|
| 540 |
|
| 541 |
+
# TOP_BEST_URLS ํญ๋ชฉ ์
|
| 542 |
+
top_best_count = len(TOP_BEST_URLS)
|
| 543 |
|
| 544 |
+
# Vercel API๋ฅผ ํตํ ์ค์ ๋ฐฐํฌ ์ (๋๋ฒ๊น
์ ์ํ ์ถ๋ ฅ ์ถ๊ฐ)
|
| 545 |
+
vercel_deployments = get_vercel_deployments()
|
| 546 |
+
print(f"Debug - Vercel API response: {vercel_deployments}") # ๋๋ฒ๊น
๋ก๊ทธ
|
| 547 |
+
actual_vercel_count = len(vercel_deployments) if vercel_deployments else 0
|
| 548 |
|
| 549 |
html_content = f"""
|
| 550 |
<div style='padding: 20px; background-color: #f5f5f5;'>
|
|
|
|
| 558 |
</a>
|
| 559 |
</p>
|
| 560 |
<p style='color: #666; margin: 0;'>
|
| 561 |
+
Found {actual_vercel_count} Vercel deployments and {len(user_spaces)} Hugging Face spaces<br>
|
| 562 |
+
(Plus {top_best_count} featured items in Top Best section)
|
| 563 |
</p>
|
| 564 |
</div>
|
| 565 |
|
|
|
|
|
|
|
| 566 |
<!-- Top Best -->
|
| 567 |
<h3 style='color: #333; margin: 20px 0;'>๐ Top Best</h3>
|
| 568 |
<div style='display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 20px;'>
|
|
|
|
| 571 |
</div>
|
| 572 |
|
| 573 |
<!-- Vercel Deployments -->
|
| 574 |
+
{f'''
|
| 575 |
<h3 style='color: #333; margin: 20px 0;'>โก Vercel Deployments</h3>
|
| 576 |
<div id="vercel-container" style='display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 20px;'>
|
| 577 |
{"".join(get_vercel_card(dep, idx) for idx, dep in enumerate(vercel_deployments))}
|
| 578 |
</div>
|
| 579 |
+
''' if vercel_deployments else ''}
|
| 580 |
|
| 581 |
<!-- Hugging Face Spaces -->
|
| 582 |
<h3 style='color: #333; margin: 20px 0;'>๐ค Hugging Face Spaces</h3>
|
|
|
|
| 586 |
</div>
|
| 587 |
|
| 588 |
<script>
|
| 589 |
+
// ... (๊ธฐ์กด ์คํฌ๋ฆฝํธ ์ฝ๋๋ ๋์ผํ๊ฒ ์ ์ง)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 590 |
</script>
|
| 591 |
"""
|
|
|
|
|
|
|
| 592 |
return html_content
|
| 593 |
|
| 594 |
except Exception as e:
|