Spaces:
Paused
Paused
Update app.py
Browse files
app.py
CHANGED
|
@@ -193,37 +193,54 @@ 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 |
try:
|
| 206 |
-
|
| 207 |
-
|
| 208 |
-
|
| 209 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 210 |
|
| 211 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 212 |
|
| 213 |
# ์ํ๊ฐ 'READY'์ด๊ณ 'url'์ด ์๋ ๋ฐฐํฌ๋ง ํํฐ๋งํ๊ณ 'javis1' ์ ์ธ
|
| 214 |
active_deployments = [
|
| 215 |
-
dep for dep in
|
| 216 |
if dep.get('state') == 'READY' and
|
| 217 |
dep.get('url') and
|
| 218 |
-
'javis1' not in dep.get('name', '').lower()
|
| 219 |
]
|
| 220 |
|
| 221 |
return active_deployments
|
|
|
|
| 222 |
except Exception as e:
|
| 223 |
print(f"Error fetching Vercel deployments: {str(e)}")
|
| 224 |
return []
|
| 225 |
|
| 226 |
-
|
| 227 |
def get_vercel_card(deployment, index):
|
| 228 |
"""Generate HTML card for a Vercel deployment with like button"""
|
| 229 |
raw_url = deployment.get('url', '')
|
|
|
|
| 193 |
"""
|
| 194 |
|
| 195 |
def get_vercel_deployments():
|
| 196 |
+
"""Vercel API๋ฅผ ํตํด ๋ฐฐํฌ๋ ์๋น์ค ์ ๋ณด ๊ฐ์ ธ์ค๊ธฐ (ํ์ด์ง๋ค์ด์
์ ์ฉ)"""
|
| 197 |
token = "A8IFZmgW2cqA4yUNlLPnci0N"
|
| 198 |
+
base_url = "https://api.vercel.com/v6/deployments"
|
| 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 |
+
while True:
|
| 210 |
+
# ๋ค์ ํ์ด์ง๊ฐ ์์ผ๋ฉด ํด๋น URL ์ฌ์ฉ, ์์ผ๋ฉด ๊ธฐ๋ณธ URL์ limit ์ ์ฉ
|
| 211 |
+
url = next_page if next_page else f"{base_url}?limit=100"
|
| 212 |
+
|
| 213 |
+
response = requests.get(url, headers=headers)
|
| 214 |
+
if response.status_code != 200:
|
| 215 |
+
print(f"Vercel API Error: {response.text}")
|
| 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 all_deployments
|
| 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 []
|
| 243 |
|
|
|
|
| 244 |
def get_vercel_card(deployment, index):
|
| 245 |
"""Generate HTML card for a Vercel deployment with like button"""
|
| 246 |
raw_url = deployment.get('url', '')
|