Download tools/build.py from DarthSoluke/EgoNetDatasetResearch: direct link, hf CLI and curl.
- Browser
- Download file 846 Bytes
-
https://huggingface.co/spaces/DarthSoluke/EgoNetDatasetResearch/resolve/main/tools/build.py
- Command line
-
hf download hf://spaces/DarthSoluke/EgoNetDatasetResearch/tools/build.py
-
curl -L -o build.py https://huggingface.co/spaces/DarthSoluke/EgoNetDatasetResearch/resolve/main/tools/build.py
846 Bytes
| #!/usr/bin/env python3 | |
| """把 src/page.html 包成完整的 index.html(Hugging Face 静态 Space 直接使用)。 | |
| python tools/build.py | |
| """ | |
| from pathlib import Path | |
| ROOT = Path(__file__).resolve().parent.parent | |
| body = (ROOT / "src/page.html").read_text(encoding="utf-8") | |
| head_end = body.index("</style>") + len("</style>") | |
| head, rest = body[:head_end], body[head_end:] | |
| html = f"""<!doctype html> | |
| <html lang="zh-CN"> | |
| <head> | |
| <meta charset="utf-8"> | |
| <meta name="viewport" content="width=device-width, initial-scale=1, viewport-fit=cover"> | |
| <style>:root{{padding-top:env(safe-area-inset-top,0px);padding-bottom:env(safe-area-inset-bottom,0px)}}img{{max-width:100%}}[hidden]{{display:none!important}}</style> | |
| {head} | |
| </head> | |
| <body> | |
| {rest} | |
| </body> | |
| </html> | |
| """ | |
| (ROOT / "index.html").write_text(html, encoding="utf-8") | |
| print("写出 index.html") | |