openfree commited on
Commit
76f9382
โ€ข
1 Parent(s): 228dd1e

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +27 -10
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
- url = "https://api.vercel.com/v6/deployments?limit=100" # limit ํŒŒ๋ผ๋ฏธํ„ฐ ์ถ”๊ฐ€
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
- if response.status_code != 200:
208
- print(f"Vercel API Error: {response.text}")
209
- return []
 
 
 
 
 
 
 
 
210
 
211
- deployments = response.json().get('deployments', [])
 
 
 
 
 
 
212
 
213
  # ์ƒํƒœ๊ฐ€ 'READY'์ด๊ณ  'url'์ด ์žˆ๋Š” ๋ฐฐํฌ๋งŒ ํ•„ํ„ฐ๋งํ•˜๊ณ  'javis1' ์ œ์™ธ
214
  active_deployments = [
215
- dep for dep in deployments
216
  if dep.get('state') == 'READY' and
217
  dep.get('url') and
218
- 'javis1' not in dep.get('name', '').lower() # javis1 ์ œ์™ธ
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', '')