Spaces:
Runtime error
Runtime error
Download app.py from ckfrpark/Free_Image1: direct link, hf CLI and curl.
- Browser
- Download file 721 Bytes
-
https://huggingface.co/spaces/ckfrpark/Free_Image1/resolve/main/app.py
- Command line
-
hf download hf://spaces/ckfrpark/Free_Image1/app.py
-
curl -L -o app.py https://huggingface.co/spaces/ckfrpark/Free_Image1/resolve/main/app.py
721 Bytes
| import requests | |
| # Pexels API 키 설정 | |
| API_KEY = 'XDDeRl6U3IY8VRzv7YBGRrnGuOwqpOYD2yS9VTAYM7VEfZcr1aWXubZ1' | |
| API_ENDPOINT = 'https://api.pexels.com/v1/search' | |
| def fetch_high_quality_images(keyword, per_page=80): | |
| headers = { | |
| 'Authorization': API_KEY | |
| } | |
| params = { | |
| 'query': keyword, | |
| 'per_page': per_page, | |
| 'size': 'large' | |
| } | |
| response = requests.get(API_ENDPOINT, headers=headers, params=params) | |
| if response.status_code == 200: | |
| data = response.json() | |
| images = data['photos'] | |
| for image in images: | |
| print(image['src']['original']) | |
| if __name__ == '__main__': | |
| keyword = input("Enter keyword: ") | |
| fetch_high_quality_images(keyword) |