Download scripts/deploy_hf_space.ps1 from nenae18/leechard: direct link, hf CLI and curl.
- Browser
- Download file 2.28 kB
-
https://huggingface.co/spaces/nenae18/leechard/resolve/main/scripts/deploy_hf_space.ps1
- Command line
-
hf download hf://spaces/nenae18/leechard/scripts/deploy_hf_space.ps1
-
curl -L -o deploy_hf_space.ps1 https://huggingface.co/spaces/nenae18/leechard/resolve/main/scripts/deploy_hf_space.ps1
2.28 kB
| param( | |
| [string]$Space = "nenae18/leechard" # "<user>/<spacename>" | |
| ) | |
| # Deploy the (flat) backend app folder straight to the Hugging Face Space. | |
| # Uses the locally CACHED HF write token (the user's fine-grained token lacks Space | |
| # write -> 403). FAL_KEY / ACCESS_CODE / ANDROID_ASSETLINKS_JSON stay as Space secrets. | |
| $ErrorActionPreference = "Stop" | |
| $Backend = Split-Path -Parent $PSScriptRoot # scripts/ lives inside backend/, parent = backend | |
| $env:HF_TOKEN = (python -c "from huggingface_hub import get_token; print(get_token() or '')").Trim() | |
| if (-not $env:HF_TOKEN -or $env:HF_TOKEN.Length -lt 10) { | |
| Write-Host "FAIL: no cached HF token. Run: python -c `"from huggingface_hub import login; login()`"" | |
| exit 1 | |
| } | |
| $bf = $Backend.Replace('\', '/') | |
| $py = @" | |
| import os | |
| from huggingface_hub import HfApi | |
| api = HfApi(token=os.environ['HF_TOKEN']) | |
| me = api.whoami() | |
| role = ((me.get('auth') or {}).get('accessToken') or {}).get('role') | |
| print('TOKEN_OK user=' + str(me.get('name')) + ' role=' + str(role)) | |
| # The Space already exists; skip create_repo (free Docker Spaces now 402 on create). | |
| # Only create as a best-effort fallback when the repo is genuinely missing. | |
| if not api.repo_exists('$Space', repo_type='space'): | |
| api.create_repo(repo_id='$Space', repo_type='space', space_sdk='docker', exist_ok=True) | |
| api.upload_folder( | |
| folder_path=r'$bf', repo_id='$Space', repo_type='space', | |
| commit_message='Deploy SalonView AI (brand single-source)', | |
| # upload_folder ๋ .gitignore ๋ฅผ ๋ณด์ง ์๋๋ค โ ์ฌ๊ธฐ ์๋ ํ์ผ์ ์ ๋ถ Space ๋ก ์ฌ๋ผ๊ฐ๋ค. | |
| # docs/ = ์์ ์๋ฃ(๊ฐ๊ฒฉํยท์ ์ฒญ์), CLAUDE.md/.claude = ๋ด๋ถ ๋ฉ๋ชจยท๊ฐ๋ฐ์ค์ . | |
| # Space ๋ ๊ณต๊ฐ๋ผ ์ ๋ ์ฌ๋ฆฌ๋ฉด ์ ๋๋ค. | |
| ignore_patterns=['tests/*', '.git/*', '**/__pycache__/*', '*.pyc', | |
| '.pytest_cache/*', '*.db', '*.db-wal', '*.db-shm', | |
| 'preview_ui*', 'dev_local*', '.env', 'docs/*', 'CLAUDE.md', '.claude/*', | |
| 'static/_shots/*', 'static/_brand_preview.html'], | |
| ) | |
| print('UPLOAD_OK') | |
| "@ | |
| $py | python - | |
| $env:HF_TOKEN = "" | |
| if ($LASTEXITCODE -ne 0) { Write-Host "FAIL: upload failed."; exit 1 } | |
| $liveHost = $Space.Replace("/", "-") | |
| Write-Host "Uploaded. Live URL after build: https://$liveHost.hf.space" | |