Download viewer.html from plan291037/TextPhantom_OCR_API2: direct link, hf CLI and curl.
- Browser
- Download file 656 Bytes
-
https://huggingface.co/spaces/plan291037/TextPhantom_OCR_API2/resolve/refs%2Fpr%2F1/viewer.html
- Command line
-
hf download hf://spaces/plan291037/TextPhantom_OCR_API2@refs/pr/1/viewer.html
-
curl -L -o viewer.html https://huggingface.co/spaces/plan291037/TextPhantom_OCR_API2/resolve/refs%2Fpr%2F1/viewer.html
656 Bytes
| export function normalizeUrl(raw) { | |
| let url = (raw || "").trim(); | |
| if (!url) return ""; | |
| if (!/^https?:\/\//i.test(url)) url = "http://" + url; | |
| try { | |
| const cleaned = url.replace(/\/+$/, ""); | |
| const u = new URL(cleaned); | |
| if (u.hostname === "0.0.0.0" || u.hostname === "127.0.0.1") { | |
| u.hostname = "localhost"; | |
| } else if (u.hostname === "[::1]") { | |
| u.hostname = "localhost"; | |
| } | |
| return u.toString().replace(/\/+$/, ""); | |
| } catch { | |
| return url.replace(/\/+$/, ""); | |
| } | |
| } | |
| export function toWs(httpBase) { | |
| const base = normalizeUrl(httpBase); | |
| if (!base) return ""; | |
| return base.replace(/^http/i, "ws") + "/ws"; | |
| } | |