Create app.py
Browse files
app.py
ADDED
@@ -0,0 +1,34 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import requests
|
2 |
+
from googletrans import Translator
|
3 |
+
|
4 |
+
# Hugging Face API ํ ํฐ ์ค์
|
5 |
+
hf_token = "YOUR_HUGGING_FACE_TOKEN"
|
6 |
+
|
7 |
+
# Google Translate ์ค๋น
|
8 |
+
translator = Translator()
|
9 |
+
|
10 |
+
# Hugging Face์์ ์ธ๊ธฐ ์๋ space ์ ๋ณด ๊ฐ์ ธ์ค๊ธฐ
|
11 |
+
def fetch_popular_spaces():
|
12 |
+
headers = {"Authorization": f"Bearer {hf_token}"}
|
13 |
+
response = requests.get("HUGGING_FACE_API_ENDPOINT", headers=headers)
|
14 |
+
spaces_data = response.json()
|
15 |
+
|
16 |
+
# ์ฌ๊ธฐ์๋ ๊ฐ์์ API ์๋ํฌ์ธํธ์ ์๋ต ๊ตฌ์กฐ๋ฅผ ์ฌ์ฉํฉ๋๋ค.
|
17 |
+
popular_spaces = spaces_data['spaces'][:20] # ์์ 20๊ฐ space ์ ํ
|
18 |
+
|
19 |
+
translated_spaces = []
|
20 |
+
for space in popular_spaces:
|
21 |
+
# Space ์ค๋ช
์ ํ๊ธ๋ก ๋ฒ์ญ
|
22 |
+
translated_desc = translator.translate(space['description'], dest='ko').text
|
23 |
+
translated_spaces.append({
|
24 |
+
'name': space['name'],
|
25 |
+
'description_ko': translated_desc
|
26 |
+
})
|
27 |
+
|
28 |
+
return translated_spaces
|
29 |
+
|
30 |
+
# ๊ฒฐ๊ณผ ์ถ๋ ฅ
|
31 |
+
if __name__ == "__main__":
|
32 |
+
popular_spaces = fetch_popular_spaces()
|
33 |
+
for space in popular_spaces:
|
34 |
+
print(f"Space ์ด๋ฆ: {space['name']}, ์ค๋ช
: {space['description_ko']}")
|