Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -26,12 +26,13 @@ def _load_best():
|
|
26 |
|
27 |
# โโโโโโโโโโโโโโโโโโโโโ 3. NEW: 6๊ธ์ vercel.app ๋ฐฐํฌ โโโโโ
|
28 |
# 3. NEW: 6๊ธ์ vercel.app ๋ฐฐํฌ
|
29 |
-
|
|
|
|
|
30 |
|
31 |
def fetch_all(limit=200):
|
32 |
"""
|
33 |
-
|
34 |
-
ยท url ํ๋์ alias ๋ฐฐ์ด์ ๋ชจ๋ ๊ฒ์
|
35 |
"""
|
36 |
try:
|
37 |
# ํ ํฐ ๊ฒ์ฆ
|
@@ -43,46 +44,58 @@ def fetch_all(limit=200):
|
|
43 |
if TEAM:
|
44 |
params["teamId"] = TEAM
|
45 |
|
46 |
-
# ์์ฒญ ๋ก๊ทธ ์ถ๊ฐ
|
47 |
print(f"Vercel API ํธ์ถ: {API}/v6/deployments (limit={limit})")
|
48 |
|
49 |
resp = requests.get(f"{API}/v6/deployments",
|
50 |
headers=HEAD, params=params, timeout=30)
|
51 |
|
52 |
-
# ์ํ ์ฝ๋ ํ์ธ ๋ฐ ์ค๋ฅ ์ฒ๋ฆฌ ๊ฐ์
|
53 |
if resp.status_code != 200:
|
54 |
print(f"API ์๋ต ์ค๋ฅ: {resp.status_code}, {resp.text[:200]}")
|
55 |
return []
|
56 |
|
57 |
data = resp.json()
|
58 |
|
59 |
-
# ๋ฐ์ดํฐ ๊ตฌ์กฐ ๊ฒ์ฆ
|
60 |
if "deployments" not in data:
|
61 |
print(f"API ์๋ต์ deployments ํ๋๊ฐ ์์ต๋๋ค: {str(data)[:200]}...")
|
62 |
return []
|
63 |
|
64 |
print(f"{len(data['deployments'])}๊ฐ์ ๋ฐฐํฌ๋ฅผ ์ฐพ์์ต๋๋ค")
|
65 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
66 |
games = []
|
67 |
for d in data.get("deployments", []):
|
68 |
if d.get("state") != "READY":
|
69 |
continue
|
70 |
|
71 |
-
#
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
if
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
86 |
return sorted(games, key=lambda x: x["ts"], reverse=True)
|
87 |
|
88 |
except Exception as e:
|
|
|
26 |
|
27 |
# โโโโโโโโโโโโโโโโโโโโโ 3. NEW: 6๊ธ์ vercel.app ๋ฐฐํฌ โโโโโ
|
28 |
# 3. NEW: 6๊ธ์ vercel.app ๋ฐฐํฌ
|
29 |
+
|
30 |
+
# ์์
|
31 |
+
PAT = re.compile(r"^[a-z0-9-]{1,}\.vercel\.app$", re.I) # 6์ ์ ํ ์ํ
|
32 |
|
33 |
def fetch_all(limit=200):
|
34 |
"""
|
35 |
+
Vercel ๋ฐฐํฌ ์ค vercel.app ๋๋ฉ์ธ์ ๊ฐ์ง ๊ฒ์ ์์ง
|
|
|
36 |
"""
|
37 |
try:
|
38 |
# ํ ํฐ ๊ฒ์ฆ
|
|
|
44 |
if TEAM:
|
45 |
params["teamId"] = TEAM
|
46 |
|
|
|
47 |
print(f"Vercel API ํธ์ถ: {API}/v6/deployments (limit={limit})")
|
48 |
|
49 |
resp = requests.get(f"{API}/v6/deployments",
|
50 |
headers=HEAD, params=params, timeout=30)
|
51 |
|
|
|
52 |
if resp.status_code != 200:
|
53 |
print(f"API ์๋ต ์ค๋ฅ: {resp.status_code}, {resp.text[:200]}")
|
54 |
return []
|
55 |
|
56 |
data = resp.json()
|
57 |
|
|
|
58 |
if "deployments" not in data:
|
59 |
print(f"API ์๋ต์ deployments ํ๋๊ฐ ์์ต๋๋ค: {str(data)[:200]}...")
|
60 |
return []
|
61 |
|
62 |
print(f"{len(data['deployments'])}๊ฐ์ ๋ฐฐํฌ๋ฅผ ์ฐพ์์ต๋๋ค")
|
63 |
|
64 |
+
# ๋๋ฒ๊น
: ์ฒซ ๋ฒ์งธ ์๋ต ํ์ ํ์ธ
|
65 |
+
if data["deployments"]:
|
66 |
+
first = data["deployments"][0]
|
67 |
+
print(f"\n์ฒซ ๋ฒ์งธ ๋ฐฐํฌ URL: {first.get('url')}")
|
68 |
+
print(f"์ฒซ ๋ฒ์งธ ๋ฐฐํฌ Alias: {first.get('alias', [])}\n")
|
69 |
+
|
70 |
+
# ํจํด ์ํ: vercel.app์ผ๋ก ๋๋๋ ๋ชจ๋ URL ํ์ฉ
|
71 |
+
domain_pat = re.compile(r"\.vercel\.app$", re.I)
|
72 |
+
|
73 |
games = []
|
74 |
for d in data.get("deployments", []):
|
75 |
if d.get("state") != "READY":
|
76 |
continue
|
77 |
|
78 |
+
# URL์ด๋ alias ์ค ํ๋๋ผ๋ vercel.app์ผ๋ก ๋๋๋ฉด ํฌํจ
|
79 |
+
url = d.get("url", "")
|
80 |
+
aliases = d.get("alias", [])
|
81 |
+
|
82 |
+
matched_url = None
|
83 |
+
if url and domain_pat.search(url):
|
84 |
+
matched_url = url
|
85 |
+
else:
|
86 |
+
for alias in aliases:
|
87 |
+
if domain_pat.search(alias):
|
88 |
+
matched_url = alias
|
89 |
+
break
|
90 |
+
|
91 |
+
if matched_url:
|
92 |
+
games.append({
|
93 |
+
"title": d.get("name", "(์ ๋ชฉ ์์)"),
|
94 |
+
"url": f"https://{matched_url}",
|
95 |
+
"ts": int(d.get("created", time.time() * 1000) / 1000)
|
96 |
+
})
|
97 |
+
|
98 |
+
print(f"vercel.app ๋๋ฉ์ธ ๋ฐฐํฌ {len(games)}๊ฐ๋ฅผ ํํฐ๋งํ์ต๋๋ค")
|
99 |
return sorted(games, key=lambda x: x["ts"], reverse=True)
|
100 |
|
101 |
except Exception as e:
|