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

Update app-backup.py

Browse files
Files changed (1) hide show
  1. app-backup.py +269 -55
app-backup.py CHANGED
@@ -195,7 +195,7 @@ def get_space_card(space, index):
195
  def get_vercel_deployments():
196
  """Vercel API๋ฅผ ํ†ตํ•ด ๋ฐฐํฌ๋œ ์„œ๋น„์Šค ์ •๋ณด ๊ฐ€์ ธ์˜ค๊ธฐ"""
197
  token = "A8IFZmgW2cqA4yUNlLPnci0N"
198
- url = "https://api.vercel.com/v6/deployments"
199
 
200
  headers = {
201
  "Authorization": f"Bearer {token}",
@@ -223,23 +223,38 @@ def get_vercel_deployments():
223
  print(f"Error fetching Vercel deployments: {str(e)}")
224
  return []
225
 
 
226
  def get_vercel_card(deployment, index):
227
  """Generate HTML card for a Vercel deployment with like button"""
228
  raw_url = deployment.get('url', '')
229
- project_name = raw_url[:6] if len(raw_url) >= 6 else raw_url
230
- url = f"{project_name}.vercel.app"
 
 
 
 
 
 
 
 
 
 
 
231
 
232
  created = format_timestamp(deployment.get('created'))
233
  name = deployment.get('name', 'Unnamed Project')
234
  state = deployment.get('state', 'N/A')
235
 
236
  # ๊ณ ์œ  ID ์ƒ์„ฑ (์นด๋“œ ์‹๋ณ„์šฉ)
237
- card_id = f"vercel-card-{project_name}"
 
 
238
 
239
  bg_color = get_pastel_color(index + 20)
240
  tech_emojis = ['โšก', '๐Ÿš€', '๐ŸŒŸ', 'โœจ', '๐Ÿ’ซ', '๐Ÿ”ฅ', '๐ŸŒˆ', '๐ŸŽฏ', '๐ŸŽจ', '๐Ÿ”ฎ']
241
  random_emojis = random.sample(tech_emojis, 3)
242
-
 
243
  return f"""
244
  <div id="{card_id}" class="vercel-card"
245
  data-likes="0"
@@ -254,28 +269,21 @@ def get_vercel_card(deployment, index):
254
  overflow: hidden;'
255
  onmouseover='this.style.transform="translateY(-5px) scale(1.02)"; this.style.boxShadow="0 8px 25px rgba(0,0,0,0.15)"'
256
  onmouseout='this.style.transform="translateY(0) scale(1)"; this.style.boxShadow="0 4px 15px rgba(0,0,0,0.1)"'>
257
- <div style='position: absolute; top: -15px; right: -15px; font-size: 100px; opacity: 0.1;'>
258
- {random_emojis[0]}
259
- </div>
260
- <div style='position: absolute; top: 10px; right: 10px; font-size: 20px;'>
261
- {random_emojis[1]}
262
- </div>
263
- <div style='position: absolute; bottom: 10px; left: 10px; font-size: 20px;'>
264
- {random_emojis[2]}
265
- </div>
266
- <h3 style='color: #2d2d2d;
267
- margin: 0 0 20px 0;
268
- font-size: 1.4em;
269
- display: flex;
270
- align-items: center;
271
- gap: 10px;'>
272
- <span style='font-size: 1.3em'>{random_emojis[0]}</span>
273
- <a href='https://{url}' target='_blank'
274
- style='text-decoration: none; color: #2d2d2d;'>
275
- {name}
276
- </a>
277
- <span style='font-size: 1.3em'>{random_emojis[1]}</span>
278
- </h3>
279
  <div style='margin: 15px 0; color: #444; background: rgba(255,255,255,0.5);
280
  padding: 15px; border-radius: 12px;'>
281
  <p style='margin: 8px 0;'>
@@ -288,35 +296,228 @@ def get_vercel_card(deployment, index):
288
  <strong>URL:</strong> ๐Ÿ”— https://{url}
289
  </p>
290
  </div>
291
- <div style='margin-top: 20px; display: flex; justify-content: space-between; align-items: center;'>
292
- <div class="like-section" style="display: flex; align-items: center; gap: 10px;">
293
- <button onclick="toggleLike('{card_id}')" class="like-button"
294
- style="background: none; border: none; cursor: pointer; font-size: 1.5em; padding: 5px 10px;">
295
- ๐Ÿค
296
- </button>
297
- <span class="like-count" style="font-size: 1.2em; color: #666;">0</span>
298
- </div>
299
- <a href='https://{url}' target='_blank'
300
- style='background: linear-gradient(45deg, #0084ff, #00a3ff);
301
- color: white;
302
- padding: 10px 20px;
303
- border-radius: 15px;
304
- text-decoration: none;
305
- display: inline-flex;
306
- align-items: center;
307
- gap: 8px;
308
- font-weight: 500;
309
- transition: all 0.3s;
310
- box-shadow: 0 2px 8px rgba(0,132,255,0.3);'
311
- onmouseover='this.style.transform="scale(1.05)"; this.style.boxShadow="0 4px 12px rgba(0,132,255,0.4)"'
312
- onmouseout='this.style.transform="scale(1)"; this.style.boxShadow="0 2px 8px rgba(0,132,255,0.3)"'>
313
- <span>View Deployment</span> ๐Ÿš€ {random_emojis[0]}
314
- </a>
315
- </div>
316
  </div>
317
  """
318
 
319
- # get_user_spaces ํ•จ์ˆ˜ ์ˆ˜์ •
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
320
  def get_user_spaces():
321
  # ๊ธฐ์กด Hugging Face ์ŠคํŽ˜์ด์Šค ๊ฐ€์ ธ์˜ค๊ธฐ
322
  url = f"https://huggingface.co/api/spaces?author={USERNAME}&limit=500"
@@ -338,6 +539,9 @@ def get_user_spaces():
338
 
339
  # Vercel ๋ฐฐํฌ ๊ฐ€์ ธ์˜ค๊ธฐ
340
  vercel_deployments = get_vercel_deployments()
 
 
 
341
 
342
  html_content = f"""
343
  <div style='padding: 20px; background-color: #f5f5f5;'>
@@ -351,9 +555,17 @@ def get_user_spaces():
351
  </a>
352
  </p>
353
  <p style='color: #666; margin: 0;'>
354
- Found {len(vercel_deployments)} Vercel deployments and {len(user_spaces)} Hugging Face spaces
355
  </p>
356
  </div>
 
 
 
 
 
 
 
 
357
 
358
  <!-- Vercel Deployments -->
359
  <h3 style='color: #333; margin: 20px 0;'>โšก Vercel Deployments</h3>
@@ -367,6 +579,7 @@ def get_user_spaces():
367
  {"".join(get_space_card(space, idx) for idx, space in enumerate(user_spaces))}
368
  </div>
369
  </div>
 
370
  <script>
371
  document.addEventListener('DOMContentLoaded', function() {{
372
  // ์ข‹์•„์š” ์ƒํƒœ ๋กœ๋“œ
@@ -420,6 +633,7 @@ def get_user_spaces():
420
  </script>
421
  """
422
 
 
423
  return html_content
424
 
425
  except Exception as e:
@@ -431,7 +645,7 @@ def get_user_spaces():
431
  <p>Please try again later.</p>
432
  </div>
433
  """
434
-
435
  # Creating the Gradio interface
436
  demo = gr.Blocks()
437
 
 
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}",
 
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', '')
230
+
231
+ # URL ์ฒ˜๋ฆฌ ๋กœ์ง ์ˆ˜์ •
232
+ if raw_url.startswith('http'):
233
+ url = raw_url # ์ „์ฒด URL์ด ์ œ๊ณต๋œ ๊ฒฝ์šฐ ๊ทธ๋Œ€๋กœ ์‚ฌ์šฉ
234
+ else:
235
+ project_name = raw_url[:6] if len(raw_url) >= 6 else raw_url
236
+ url = f"{project_name}.vercel.app"
237
+
238
+ # Hugging Face ์ŠคํŽ˜์ด์Šค URL์ธ ๊ฒฝ์šฐ ์ง์ ‘ ์‚ฌ์šฉ
239
+ if 'huggingface.co' in url:
240
+ final_url = url
241
+ else:
242
+ final_url = f"https://{url}" if not url.startswith('http') else url
243
 
244
  created = format_timestamp(deployment.get('created'))
245
  name = deployment.get('name', 'Unnamed Project')
246
  state = deployment.get('state', 'N/A')
247
 
248
  # ๊ณ ์œ  ID ์ƒ์„ฑ (์นด๋“œ ์‹๋ณ„์šฉ)
249
+ card_id = f"vercel-card-{url.replace('.', '-').replace('/', '-')}"
250
+
251
+
252
 
253
  bg_color = get_pastel_color(index + 20)
254
  tech_emojis = ['โšก', '๐Ÿš€', '๐ŸŒŸ', 'โœจ', '๐Ÿ’ซ', '๐Ÿ”ฅ', '๐ŸŒˆ', '๐ŸŽฏ', '๐ŸŽจ', '๐Ÿ”ฎ']
255
  random_emojis = random.sample(tech_emojis, 3)
256
+
257
+
258
  return f"""
259
  <div id="{card_id}" class="vercel-card"
260
  data-likes="0"
 
269
  overflow: hidden;'
270
  onmouseover='this.style.transform="translateY(-5px) scale(1.02)"; this.style.boxShadow="0 8px 25px rgba(0,0,0,0.15)"'
271
  onmouseout='this.style.transform="translateY(0) scale(1)"; this.style.boxShadow="0 4px 15px rgba(0,0,0,0.1)"'>
272
+ <!-- ... (์ด์ „ ์ฝ”๋“œ์™€ ๋™์ผ) ... -->
273
+ <h3 style='color: #2d2d2d;
274
+ margin: 0 0 20px 0;
275
+ font-size: 1.4em;
276
+ display: flex;
277
+ align-items: center;
278
+ gap: 10px;'>
279
+ <span style='font-size: 1.3em'>{random_emojis[0]}</span>
280
+ <a href='{final_url}' target='_blank'
281
+ style='text-decoration: none; color: #2d2d2d;'>
282
+ {name}
283
+ </a>
284
+ <span style='font-size: 1.3em'>{random_emojis[1]}</span>
285
+ </h3>
286
+
 
 
 
 
 
 
 
287
  <div style='margin: 15px 0; color: #444; background: rgba(255,255,255,0.5);
288
  padding: 15px; border-radius: 12px;'>
289
  <p style='margin: 8px 0;'>
 
296
  <strong>URL:</strong> ๐Ÿ”— https://{url}
297
  </p>
298
  </div>
299
+ <div style='margin-top: 20px; display: flex; justify-content: space-between; align-items: center;'>
300
+ <div class="like-section" style="display: flex; align-items: center; gap: 10px;">
301
+ <button onclick="toggleLike('{card_id}')" class="like-button"
302
+ style="background: none; border: none; cursor: pointer; font-size: 1.5em; padding: 5px 10px;">
303
+ ๐Ÿค
304
+ </button>
305
+ <span class="like-count" style="font-size: 1.2em; color: #666;">0</span>
306
+ </div>
307
+ <a href='{final_url}' target='_blank'
308
+ style='background: linear-gradient(45deg, #0084ff, #00a3ff);
309
+ color: white;
310
+ padding: 10px 20px;
311
+ border-radius: 15px;
312
+ text-decoration: none;
313
+ display: inline-flex;
314
+ align-items: center;
315
+ gap: 8px;
316
+ font-weight: 500;
317
+ transition: all 0.3s;
318
+ box-shadow: 0 2px 8px rgba(0,132,255,0.3);'
319
+ onmouseover='this.style.transform="scale(1.05)"; this.style.boxShadow="0 4px 12px rgba(0,132,255,0.4)"'
320
+ onmouseout='this.style.transform="scale(1)"; this.style.boxShadow="0 2px 8px rgba(0,132,255,0.3)"'>
321
+ <span>View Deployment</span> ๐Ÿš€ {random_emojis[0]}
322
+ </a>
323
+ </div>
324
  </div>
325
  """
326
 
327
+ # Top Best URLs ์ •์˜
328
+ TOP_BEST_URLS = [
329
+
330
+ {
331
+ "url": "dekvxz.vercel.app",
332
+ "name": "[๊ฒŒ์ž„] ๋‹ค์ด์–ดํŠธ ํ—Œํ„ฐ",
333
+ "created": "2024-11-20 00:00",
334
+ "state": "READY"
335
+ },
336
+ {
337
+ "url": "jtufui.vercel.app",
338
+ "name": "[๊ฒŒ์ž„] ํ…Œ๋Ÿฌ๋ฆฌ์ŠคํŠธ",
339
+ "created": "2024-11-20 00:00",
340
+ "state": "READY"
341
+ },
342
+ {
343
+ "url": "https://huggingface.co/spaces/openfree/ggumim",
344
+ "name": "[MOUSE-II] ์ด๋ฏธ์ง€์— ํ•œ๊ธ€ ์ถœ๋ ฅ",
345
+ "created": "2024-11-18 00:00",
346
+ "state": "READY"
347
+ },
348
+ {
349
+ "url": "xabtnc.vercel.app",
350
+ "name": "[ChatGPT] ๋‚˜๋งŒ์˜ LLM",
351
+ "created": "2024-11-18 00:00",
352
+ "state": "READY"
353
+ },
354
+ {
355
+ "url": "https://huggingface.co/spaces/openfree/ifbhdc",
356
+ "name": "[๊ฒŒ์ž„] ๋ณด์„ ํŒกํŒก",
357
+ "created": "2024-11-18 00:00",
358
+ "state": "READY"
359
+ },
360
+ {
361
+ "url": "nxhquk.vercel.app",
362
+ "name": "[๊ฒŒ์ž„] ํ…ŒํŠธ๋ฆฌ์Šค",
363
+ "created": "2024-11-18 00:00",
364
+ "state": "READY"
365
+ },
366
+ {
367
+ "url": "bydcnd.vercel.app",
368
+ "name": "[๋ชจ๋ธ] 3D ๋ถ„์ž ๋ชจํ˜•",
369
+ "created": "2024-11-18 00:00",
370
+ "state": "READY"
371
+ },
372
+ {
373
+ "url": "ijhama.vercel.app",
374
+ "name": "ํˆฌ์ž ํฌํŠธํด๋ฆฌ์˜ค ๋ถ„์„",
375
+ "created": "2024-11-18 00:00",
376
+ "state": "READY"
377
+ },
378
+ {
379
+ "url": "oschnl.vercel.app",
380
+ "name": "๋กœ๋˜ ๋ฒˆํ˜ธ ๋ถ„์„/์ถ”์ฒœ",
381
+ "created": "2024-11-18 00:00",
382
+ "state": "READY"
383
+ },
384
+ {
385
+ "url": "rzwzrq.vercel.app",
386
+ "name": "์—‘์…€/CSV ๋ฐ์ดํ„ฐ ๋ถ„์„",
387
+ "created": "2024-11-18 00:00",
388
+ "state": "READY"
389
+ },
390
+ {
391
+ "url": "twkqre.vercel.app",
392
+ "name": "[์šด์„ธ] ํƒ€๋กœ์นด๋“œ",
393
+ "created": "2024-11-18 00:00",
394
+ "state": "READY"
395
+ },
396
+ {
397
+ "url": "htwymz.vercel.app",
398
+ "name": "[๊ฒŒ์ž„] ์†Œ๋ฐฉํ—ฌ๊ธฐ",
399
+ "created": "2024-11-20 00:00",
400
+ "state": "READY"
401
+ },
402
+ {
403
+ "url": "mktmbn.vercel.app",
404
+ "name": "[๊ฒŒ์ž„] ์šฐ์ฃผ์ „์Ÿ",
405
+ "created": "2024-11-19 00:00",
406
+ "state": "READY"
407
+ },
408
+ {
409
+ "url": "euguwt.vercel.app",
410
+ "name": "[๊ฒŒ์ž„] ํฌ์„ธ์ด๋ˆ",
411
+ "created": "2024-11-19 00:00",
412
+ "state": "READY"
413
+ },
414
+ {
415
+ "url": "qmdzoh.vercel.app",
416
+ "name": "[๊ฒŒ์ž„] ํ•˜๋Š˜์„ ์ง€์ผœ๋ผ",
417
+ "created": "2024-11-19 00:00",
418
+ "state": "READY"
419
+ },
420
+ {
421
+ "url": "kofaqo.vercel.app",
422
+ "name": "[๊ฒŒ์ž„] ์šด์„ ์ถฉ๋Œ!",
423
+ "created": "2024-11-19 00:00",
424
+ "state": "READY"
425
+ },
426
+ {
427
+ "url": "qoqqkq.vercel.app",
428
+ "name": "[๊ฒŒ์ž„] ๋‘๋”์ฅ ์žก๊ธฐ",
429
+ "created": "2024-11-19 00:00",
430
+ "state": "READY"
431
+ },
432
+ {
433
+ "url": "nmznel.vercel.app",
434
+ "name": "[๊ฒŒ์ž„] ๊ณ ์–‘์ด ์ „์šฉ",
435
+ "created": "2024-11-19 00:00",
436
+ "state": "READY"
437
+ },
438
+
439
+
440
+ {
441
+ "url": "psrrtp.vercel.app",
442
+ "name": "[๋Œ€์‹œ๋ณด๋“œ] ์„ธ๊ณ„ ์ธ๊ตฌ",
443
+ "created": "2024-11-18 00:00",
444
+ "state": "READY"
445
+ },
446
+ {
447
+ "url": "xxloav.vercel.app",
448
+ "name": "[๊ฒŒ์ž„] ๋ฒฝ๋Œ ๊นจ๊ธฐ",
449
+ "created": "2024-11-18 00:00",
450
+ "state": "READY"
451
+ },
452
+ {
453
+ "url": "https://huggingface.co/spaces/openfree/edpaje",
454
+ "name": "[๊ฒŒ์ž„] ๊ธฐ์–ต๋ ฅ ์นด๋“œ",
455
+ "created": "2024-11-18 00:00",
456
+ "state": "READY"
457
+ },
458
+ {
459
+ "url": "https://huggingface.co/spaces/openfree/ixtidb",
460
+ "name": "AI ์š”๋ฆฌ์‚ฌ",
461
+ "created": "2024-11-18 00:00",
462
+ "state": "READY"
463
+ },
464
+
465
+ {
466
+ "url": "cnlzji.vercel.app",
467
+ "name": "๊ตญ๊ฐ€ ์ •๋ณด ๋น„๊ต",
468
+ "created": "2024-11-18 00:00",
469
+ "state": "READY"
470
+ },
471
+ {
472
+ "url": "fazely.vercel.app",
473
+ "name": "Wikipedia ์ง€์‹ ๋ถ„์„",
474
+ "created": "2024-11-18 00:00",
475
+ "state": "READY"
476
+ },
477
+ {
478
+ "url": "pkzhbo.vercel.app",
479
+ "name": "์„ธ๊ณ„ ๊ตญ๊ฐ€๋ณ„ ์‹œ๊ฐ„๋Œ€",
480
+ "created": "2024-11-18 00:00",
481
+ "state": "READY"
482
+ },
483
+ {
484
+ "url": "pammgl.vercel.app",
485
+ "name": "๋ณด๋„์ž๋ฃŒ ๋ฐฐํฌ ์„œ๋น„์Šค",
486
+ "created": "2024-11-18 00:00",
487
+ "state": "READY"
488
+ },
489
+
490
+
491
+ {
492
+ "url": "https://ktduhm.vercel.app/",
493
+ "name": "์ˆ˜ํ•™์„ ๊ทธ๋ž˜ํ”„๋กœ ์ดํ•ด",
494
+ "created": "2024-11-18 00:00",
495
+ "state": "READY"
496
+ },
497
+
498
+
499
+ {
500
+ "url": "vjmfoy.vercel.app",
501
+ "name": "[๊ฒŒ์ž„] 3D ๋ฒฝ๋Œ์Œ“๊ธฐ",
502
+ "created": "2024-11-18 00:00",
503
+ "state": "READY"
504
+ },
505
+ {
506
+ "url": "aodakf.vercel.app",
507
+ "name": "[๋ฒ„์ถ”์–ผ] 3D ๊ฐ€์ƒํ˜„์‹ค",
508
+ "created": "2024-11-18 00:00",
509
+ "state": "READY"
510
+ },
511
+ {
512
+ "url": "mxoeue.vercel.app",
513
+ "name": "์Œ์„ฑ ์ƒ์„ฑ(TTS),์กฐ์ •",
514
+ "created": "2024-11-18 00:00",
515
+ "state": "READY"
516
+ }
517
+ ]
518
+
519
+
520
+
521
  def get_user_spaces():
522
  # ๊ธฐ์กด Hugging Face ์ŠคํŽ˜์ด์Šค ๊ฐ€์ ธ์˜ค๊ธฐ
523
  url = f"https://huggingface.co/api/spaces?author={USERNAME}&limit=500"
 
539
 
540
  # Vercel ๋ฐฐํฌ ๊ฐ€์ ธ์˜ค๊ธฐ
541
  vercel_deployments = get_vercel_deployments()
542
+
543
+ # ์ˆœ์ˆ˜ Vercel ๋ฐฐํฌ ์ˆ˜๋งŒ ์นด์šดํŠธ
544
+ vercel_count = len(vercel_deployments) if vercel_deployments else 0
545
 
546
  html_content = f"""
547
  <div style='padding: 20px; background-color: #f5f5f5;'>
 
555
  </a>
556
  </p>
557
  <p style='color: #666; margin: 0;'>
558
+ Found {vercel_count} Vercel deployments and {len(user_spaces)} Hugging Face spaces
559
  </p>
560
  </div>
561
+
562
+
563
+ <!-- Top Best -->
564
+ <h3 style='color: #333; margin: 20px 0;'>๐Ÿ† Top Best</h3>
565
+ <div style='display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 20px;'>
566
+ {"".join(get_vercel_card({"url": url["url"], "created": url["created"], "name": url["name"], "state": url["state"]}, idx)
567
+ for idx, url in enumerate(TOP_BEST_URLS))}
568
+ </div>
569
 
570
  <!-- Vercel Deployments -->
571
  <h3 style='color: #333; margin: 20px 0;'>โšก Vercel Deployments</h3>
 
579
  {"".join(get_space_card(space, idx) for idx, space in enumerate(user_spaces))}
580
  </div>
581
  </div>
582
+
583
  <script>
584
  document.addEventListener('DOMContentLoaded', function() {{
585
  // ์ข‹์•„์š” ์ƒํƒœ ๋กœ๋“œ
 
633
  </script>
634
  """
635
 
636
+
637
  return html_content
638
 
639
  except Exception as e:
 
645
  <p>Please try again later.</p>
646
  </div>
647
  """
648
+
649
  # Creating the Gradio interface
650
  demo = gr.Blocks()
651