Download help.py from Mohamed424/stroke-segmentation-backend: direct link, hf CLI and curl.
- Browser
- Download file 1.16 kB
-
https://huggingface.co/spaces/Mohamed424/stroke-segmentation-backend/resolve/main/help.py
- Command line
-
hf download hf://spaces/Mohamed424/stroke-segmentation-backend/help.py
-
curl -L -o help.py https://huggingface.co/spaces/Mohamed424/stroke-segmentation-backend/resolve/main/help.py
1.16 kB
| # upload_env_to_hf.py | |
| from huggingface_hub import HfApi | |
| import os, re | |
| SPACE_ID = "Mohamed424/stroke-segmentation-backend" | |
| ENV_PATH = ".env" | |
| # Keys that should be stored as **Secrets** (private) | |
| SECRET_KEYS = { | |
| "SECRET_KEY", | |
| "MONGODB_URL", | |
| "CLOUDINARY_API_KEY", | |
| "CLOUDINARY_API_SECRET", | |
| } | |
| api = HfApi() | |
| def parse_env(path): | |
| items = [] | |
| with open(path, "r", encoding="utf-8") as f: | |
| for raw in f: | |
| line = raw.strip() | |
| if not line or line.startswith("#"): | |
| continue | |
| # split on the first "=" only | |
| if "=" not in line: | |
| continue | |
| k, v = line.split("=", 1) | |
| k = k.strip() | |
| v = v.strip().strip('"').strip("'") | |
| items.append((k, v)) | |
| return items | |
| pairs = parse_env(ENV_PATH) | |
| for key, val in pairs: | |
| if key in SECRET_KEYS: | |
| print(f"[secret] {key}") | |
| api.add_space_secret(repo_id=SPACE_ID, key=key, value=val) | |
| else: | |
| print(f"[variable] {key}") | |
| api.add_space_variable(repo_id=SPACE_ID, key=key, value=val) | |
| print("✅ Done. Variables & secrets are now set on the Space.") | |