ginipick commited on
Commit
8e9ec52
ยท
verified ยท
1 Parent(s): 3cd46cc

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +24 -8
app.py CHANGED
@@ -76,15 +76,31 @@ def process_url_for_iframe(url):
76
  # ํ—ˆ๊น…ํŽ˜์ด์Šค URL ํŒจํ„ด ๊ฐ์ง€
77
  is_huggingface = False
78
 
79
- # .hf.space ๋„๋ฉ”์ธ ๋˜๋Š” huggingface.co ํŒจํ„ด ํ™•์ธ
80
- if ".hf.space" in url or "huggingface.co" in url:
81
  is_huggingface = True
82
-
83
- # huggingface.co/spaces ํŒจํ„ด์— /embed ์ถ”๊ฐ€ (์ด๋ฏธ ์—†๋Š” ๊ฒฝ์šฐ)
84
- if "huggingface.co/spaces" in url and not url.endswith("/embed"):
85
- url = url.rstrip("/")
86
- url = f"{url}/embed"
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
87
 
 
88
  return url, is_huggingface
89
 
90
  # โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€ 6. HTML ๊ทธ๋ฆฌ๋“œ โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€
@@ -260,7 +276,7 @@ def html(cards, pg, total):
260
  width="100%"
261
  height="100%"
262
  allowfullscreen="true"
263
- allow="accelerometer; camera; encrypted-media; gyroscope; microphone;"
264
  sandbox="allow-forms allow-modals allow-popups allow-popups-to-escape-sandbox allow-same-origin allow-scripts allow-downloads">
265
  </iframe>
266
  </div>
 
76
  # ํ—ˆ๊น…ํŽ˜์ด์Šค URL ํŒจํ„ด ๊ฐ์ง€
77
  is_huggingface = False
78
 
79
+ # huggingface.co/spaces ํŒจํ„ด ์ฒ˜๋ฆฌ
80
+ if "huggingface.co/spaces" in url:
81
  is_huggingface = True
82
+ try:
83
+ # URL์—์„œ owner์™€ name ์ถ”์ถœ
84
+ parts = url.split('/spaces/')[1].split('/')
85
+ owner = parts[0]
86
+ name = parts[1] if len(parts) > 1 else ""
87
+
88
+ # ํŠน์ˆ˜ ๋ฌธ์ž ์ฒ˜๋ฆฌ ๋ฐ ์†Œ๋ฌธ์ž ๋ณ€ํ™˜
89
+ name = name.replace('.', '-').replace('_', '-').lower()
90
+ owner = owner.lower()
91
+
92
+ # ์ƒˆ URL ํ˜•์‹ ์ ์šฉ
93
+ return f"https://{owner}-{name}.hf.space", is_huggingface
94
+ except:
95
+ # ์˜ค๋ฅ˜ ๋ฐœ์ƒ์‹œ ์›๋ž˜ URL ์‚ฌ์šฉ
96
+ return url, is_huggingface
97
+
98
+ # ์ด๋ฏธ .hf.space ๋„๋ฉ”์ธ์ธ ๊ฒฝ์šฐ
99
+ elif ".hf.space" in url:
100
+ is_huggingface = True
101
+ return url, is_huggingface
102
 
103
+ # ์ผ๋ฐ˜ URL์€ ๊ทธ๋Œ€๋กœ ๋ฐ˜ํ™˜
104
  return url, is_huggingface
105
 
106
  # โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€ 6. HTML ๊ทธ๋ฆฌ๋“œ โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€
 
276
  width="100%"
277
  height="100%"
278
  allowfullscreen="true"
279
+ allow="accelerometer; camera; encrypted-media; gyroscope; geolocation;"
280
  sandbox="allow-forms allow-modals allow-popups allow-popups-to-escape-sandbox allow-same-origin allow-scripts allow-downloads">
281
  </iframe>
282
  </div>