Spaces:
Running
Running
File size: 857 Bytes
72eef4f |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
from huggingface_hub import HfApi
from dotenv import dotenv_values
# Load .env variables (dotenv_values returns a dict)
env_vars = dotenv_values(r'C:\Users\Vaibhav Arora\Documents\MyExperimentsandCodes\APPS_WEBSITES\CANADA_WHOLESALE_PROJECT\GITHUB_REPOS\mvp-vue\wholesale-grocery-app\AIAPPS\.env')
# Initialize API
api = HfApi(token=env_vars.get("HF_TOKEN"))
# Space repo ID (username_or_org/space_name)
REPO_ID = "akiko19191/randomisedbackend2"
# Loop through all variables in .env and add them as Space secrets
for key, value in env_vars.items():
print(value)
if value is None:
continue # skip empty entries
print(f"Setting secret: {key}")
api.add_space_secret(
repo_id=REPO_ID,
key=key,
value=value
)
print("✅ All .env variables uploaded as Hugging Face Space secrets.") |