Spaces:
Paused
Paused
Download src/dashboard/static/api-client.js from ThomasHeisig/Brain-5D-Space: direct link, hf CLI and curl.
- Browser
- Download file 692 Bytes
-
https://huggingface.co/spaces/ThomasHeisig/Brain-5D-Space/resolve/main/src/dashboard/static/api-client.js
- Command line
-
hf download hf://spaces/ThomasHeisig/Brain-5D-Space/src/dashboard/static/api-client.js
-
curl -L -o api-client.js https://huggingface.co/spaces/ThomasHeisig/Brain-5D-Space/resolve/main/src/dashboard/static/api-client.js
692 Bytes
| /** | |
| * Shared dashboard API helpers for browser and Hugging Face Space deployments. | |
| */ | |
| ; | |
| const isHuggingFaceHost = () => /\.hf\.space$/i.test(window.location.hostname); | |
| export const isHuggingFaceSpace = isHuggingFaceHost(); | |
| export function pollInterval(milliseconds) { | |
| return isHuggingFaceSpace ? milliseconds * 4 : milliseconds; | |
| } | |
| export async function readJson(response) { | |
| const contentType = response.headers.get("content-type") || "unknown"; | |
| const body = await response.text(); | |
| if (!body) return {}; | |
| try { | |
| return JSON.parse(body); | |
| } catch { | |
| throw new Error( | |
| `API returned non-JSON data (HTTP ${response.status}, ${contentType})`, | |
| ); | |
| } | |
| } |