Spaces:
Build error
Build error
Download app/util/parameter_utils.py from spunteam/api-web-crawler: direct link, hf CLI and curl.
- Browser
- Download file 723 Bytes
-
https://huggingface.co/spaces/spunteam/api-web-crawler/resolve/main/app/util/parameter_utils.py
- Command line
-
hf download hf://spaces/spunteam/api-web-crawler/app/util/parameter_utils.py
-
curl -L -o parameter_utils.py https://huggingface.co/spaces/spunteam/api-web-crawler/resolve/main/app/util/parameter_utils.py
723 Bytes
| # parameter_utils.py | |
| import os | |
| import boto3 | |
| ssm = boto3.client('ssm', region_name='ap-southeast-3') | |
| def init_secret(path): | |
| next_token = None | |
| while True: | |
| response = ssm.get_parameters_by_path( | |
| Path=path, | |
| Recursive=True, | |
| WithDecryption=True, | |
| NextToken=next_token if next_token else "", | |
| ) | |
| parameters = response.get("Parameters", []) | |
| for parameter in parameters: | |
| key = parameter.get("Name").split("/")[-1] | |
| value = parameter.get("Value") | |
| os.environ[key] = value | |
| print(f"Set env variable {key}") | |
| next_token = response.get("NextToken") | |
| if not next_token: | |
| break | |