Download app.py from honey90/hugging: direct link, hf CLI and curl.
- Browser
- Download file 1.15 kB
-
https://huggingface.co/spaces/honey90/hugging/resolve/main/app.py
- Command line
-
hf download hf://spaces/honey90/hugging/app.py
-
curl -L -o app.py https://huggingface.co/spaces/honey90/hugging/resolve/main/app.py
1.15 kB
| import requests | |
| from googletrans import Translator | |
| # Hugging Face API ํ ํฐ ์ค์ | |
| hf_token = "YOUR_HUGGING_FACE_TOKEN" | |
| # Google Translate ์ค๋น | |
| translator = Translator() | |
| # Hugging Face์์ ์ธ๊ธฐ ์๋ space ์ ๋ณด ๊ฐ์ ธ์ค๊ธฐ | |
| def fetch_popular_spaces(): | |
| headers = {"Authorization": f"Bearer {hf_token}"} | |
| response = requests.get("HUGGING_FACE_API_ENDPOINT", headers=headers) | |
| spaces_data = response.json() | |
| # ์ฌ๊ธฐ์๋ ๊ฐ์์ API ์๋ํฌ์ธํธ์ ์๋ต ๊ตฌ์กฐ๋ฅผ ์ฌ์ฉํฉ๋๋ค. | |
| popular_spaces = spaces_data['spaces'][:20] # ์์ 20๊ฐ space ์ ํ | |
| translated_spaces = [] | |
| for space in popular_spaces: | |
| # Space ์ค๋ช ์ ํ๊ธ๋ก ๋ฒ์ญ | |
| translated_desc = translator.translate(space['description'], dest='ko').text | |
| translated_spaces.append({ | |
| 'name': space['name'], | |
| 'description_ko': translated_desc | |
| }) | |
| return translated_spaces | |
| # ๊ฒฐ๊ณผ ์ถ๋ ฅ | |
| if __name__ == "__main__": | |
| popular_spaces = fetch_popular_spaces() | |
| for space in popular_spaces: | |
| print(f"Space ์ด๋ฆ: {space['name']}, ์ค๋ช : {space['description_ko']}") |