randomisedbackend2 / hfapis.py
akiko19191's picture
Upload folder using huggingface_hub
72eef4f verified
raw
history blame
857 Bytes
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.")