Spaces:
Running
Running
Download index.html from gretchenboria/PixieDuster: direct link, hf CLI and curl.
- Browser
- Download file 6.32 kB
-
https://huggingface.co/spaces/gretchenboria/PixieDuster/resolve/main/index.html
- Command line
-
hf download hf://spaces/gretchenboria/PixieDuster/index.html
-
curl -L -o index.html https://huggingface.co/spaces/gretchenboria/PixieDuster/resolve/main/index.html
6.32 kB
| <html> | |
| <head> | |
| <meta charset="UTF-8" /> | |
| <meta http-equiv="X-UA-Compatible" content="IE=edge" /> | |
| <meta | |
| name="viewport" | |
| content="width=device-width, initial-scale=1, shrink-to-fit=no" | |
| /> | |
| <title>PixieDuster - AI Persona Cloning</title> | |
| <!-- Turnstile: proves the visitor is a person, so the hosted key can be | |
| used without anyone typing a key of their own. The sitekey is public | |
| by design; the matching secret lives only on the Worker. --> | |
| <!-- Turnstile script moved to body to prevent race condition --> | |
| <style> | |
| html, body { margin: 0; background: #0f081c; } | |
| /* Normal flow, pinned to the top. `position: fixed` centerd this in the | |
| middle of Hugging Face's very tall iframe, which put it below the fold. */ | |
| #pd-gate { | |
| display: flex; flex-direction: column; align-items: center; | |
| gap: 16px; padding: 56px 20px 72px; | |
| background: radial-gradient(circle at top, #2b1845, #0f081c); | |
| color: #e2d1f9; font-family: Inter, system-ui, sans-serif; text-align: center; | |
| min-height: 60vh; box-sizing: border-box; | |
| } | |
| #pd-gate img { width: 96px; filter: drop-shadow(0 0 14px rgba(255,215,0,.35)); } | |
| #pd-gate h1 { color: #ffd700; font-size: 1.6rem; margin: 0; letter-spacing: .5px; } | |
| #pd-gate p { color: #d1c4e9; max-width: 32rem; margin: 0; font-size: .95rem; line-height: 1.5; } | |
| #pd-turnstile { min-height: 65px; } | |
| #pd-gate.done { display: none; } | |
| #root { display: none; } | |
| #root.ready { display: block; } | |
| </style> | |
| <!-- Stlite CSS --> | |
| <link | |
| rel="stylesheet" | |
| href="https://cdn.jsdelivr.net/npm/@stlite/mountable@0.75.0/build/stlite.css" | |
| /> | |
| </head> | |
| <body> | |
| <div id="pd-gate"> | |
| <img src="./logo.png" alt=""> | |
| <h1>PixieDuster</h1> | |
| <p>One quick check that you are a person, then you are in. No sign-up, | |
| no API key, nothing to install.</p> | |
| <div id="pd-turnstile"></div> | |
| <p id="pd-status" style="font-size:.8rem;color:#8a7da3;">Loading…</p> | |
| </div> | |
| <div id="root"></div> | |
| <!-- Stlite JS --> | |
| <script src="https://cdn.jsdelivr.net/npm/@stlite/mountable@0.75.0/build/stlite.js"></script> | |
| <script> | |
| // Exchange one Turnstile pass for a short-lived session the Python app | |
| // reads out of window.pdSession. Tokens are single-use; a session is not. | |
| window.pdApi = "https://pixieduster-api.me-c41.workers.dev/api"; | |
| window.pdSession = ""; | |
| // Two things must finish before the app is usable: the human check, | |
| // and stlite compiling Streamlit's stack in the browser. Revealing on | |
| // the first alone drops the visitor onto a blank page. | |
| var pdChecked = false; | |
| var pdMounted = false; | |
| function pdMaybeReady() { | |
| var status = document.getElementById("pd-status"); | |
| if (!pdChecked) return; | |
| if (!pdMounted) { | |
| status.textContent = | |
| "Starting up. The first load takes a few seconds; it is building " + | |
| "Python in your browser."; | |
| return; | |
| } | |
| status.textContent = ""; | |
| document.getElementById("pd-gate").classList.add("done"); | |
| document.getElementById("root").classList.add("ready"); | |
| } | |
| function pdReady() { | |
| pdChecked = true; | |
| pdMaybeReady(); | |
| } | |
| // Streamlit gives no ready event here, so watch for it painting. | |
| new MutationObserver(function (records, observer) { | |
| var root = document.getElementById("root"); | |
| if (root && root.querySelector('[data-testid="stAppViewContainer"], .stApp')) { | |
| pdMounted = true; | |
| observer.disconnect(); | |
| pdMaybeReady(); | |
| } | |
| }).observe(document.getElementById("root"), { childList: true, subtree: true }); | |
| async function pdVerified(token) { | |
| const status = document.getElementById("pd-status"); | |
| status.textContent = "Checking…"; | |
| try { | |
| const r = await fetch(window.pdApi + "/session", { | |
| method: "POST", | |
| headers: { "x-turnstile-token": token }, | |
| }); | |
| if (!r.ok) throw new Error(await r.text()); | |
| window.pdSession = (await r.json()).session; | |
| window.localStorage.setItem("pdSession", window.pdSession); | |
| // Mount stlite ONLY AFTER we have the session token, and pass it directly as a Python module! | |
| stlite.mount( | |
| { | |
| requirements: ["requests"], | |
| entrypoint: "app.py", | |
| files: { | |
| "app.py": { | |
| url: "./app.py?v=" + Date.now(), | |
| }, | |
| "logo.png": { | |
| url: "./logo.png", | |
| }, | |
| "session_token.py": "TOKEN = '" + window.pdSession + "'\n" | |
| }, | |
| }, | |
| document.getElementById("root") | |
| ); | |
| pdReady(); | |
| } catch (e) { | |
| status.textContent = | |
| "Could not start a session. Reload the page, or use the CLI with your own key."; | |
| console.error(e); | |
| } | |
| } | |
| // If the challenge never resolves, say so rather than sitting on | |
| // "Loading..." forever -- and offer the way out that always works. | |
| function pdStall() { | |
| if (window.pdSession) return; | |
| document.getElementById("pd-status").innerHTML = | |
| 'Still waiting on the human check. Try reloading, or ' + | |
| '<a href="https://github.com/gretchenboria/PixieDuster" style="color:#ffd700;">' + | |
| 'use the command line version</a>.'; | |
| } | |
| window.onloadTurnstileCallback = function () { | |
| document.getElementById("pd-status").textContent = ""; | |
| setTimeout(pdStall, 12000); | |
| turnstile.render("#pd-turnstile", { | |
| sitekey: "0x4AAAAAAEb4atlzbWGoBrFJ", | |
| theme: "dark", | |
| callback: pdVerified, | |
| "error-callback": function () { | |
| document.getElementById("pd-status").textContent = | |
| "Verification failed. Reload the page to try again."; | |
| }, | |
| }); | |
| }; | |
| </script> | |
| <script src="https://challenges.cloudflare.com/turnstile/v0/api.js?onload=onloadTurnstileCallback&render=explicit" async defer></script> | |
| </body> | |
| </html> | |