clo-up / client-hf.html
ADXabhi's picture
Upload 5 files
e56b6fb verified
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Hugging Face Video Uploader</title>
<style>
:root {
--primary: #facc15;
/* HF Yellow/Orange tone */
--bg: #0b0f19;
--surface: #1f2937;
--text: #f3f4f6;
}
body {
font-family: 'Inter', system-ui, sans-serif;
background: var(--bg);
color: var(--text);
display: flex;
justify-content: center;
align-items: center;
min-height: 100vh;
margin: 0;
}
.container {
background: var(--surface);
padding: 2rem;
border-radius: 12px;
width: 100%;
max-width: 500px;
box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.5);
border: 1px solid #374151;
}
h2 {
margin-top: 0;
text-align: center;
color: var(--primary);
}
.form-group {
margin-bottom: 1.5rem;
}
label {
display: block;
margin-bottom: 0.5rem;
font-size: 0.9rem;
color: #d1d5db;
}
input {
width: 100%;
padding: 0.75rem;
background: #111827;
border: 1px solid #374151;
border-radius: 6px;
color: white;
box-sizing: border-box;
}
input:focus {
outline: 2px solid var(--primary);
border-color: transparent;
}
button {
width: 100%;
padding: 0.75rem;
background: var(--primary);
color: #1f2937;
border: none;
border-radius: 6px;
font-weight: 700;
cursor: pointer;
transition: transform 0.1s;
}
button:hover {
opacity: 0.9;
transform: scale(1.02);
}
button:disabled {
opacity: 0.5;
cursor: not-allowed;
transform: none;
}
#results {
margin-top: 2rem;
display: none;
}
.result-item {
background: #111827;
padding: 0.75rem;
border-radius: 6px;
margin-bottom: 0.5rem;
word-break: break-all;
font-size: 0.85rem;
border: 1px solid #374151;
display: flex;
justify-content: space-between;
align-items: center;
}
.copy-btn {
background: #374151;
border: none;
color: white;
padding: 4px 8px;
border-radius: 4px;
font-size: 0.75rem;
cursor: pointer;
width: auto;
margin-left: 10px;
}
.loader {
display: none;
text-align: center;
margin-top: 1rem;
color: #9ca3af;
}
/* HF Emoji */
.hf-logo {
font-size: 3rem;
display: block;
text-align: center;
margin-bottom: 1rem;
}
</style>
</head>
<body>
<div class="container">
<div class="hf-logo">🤗</div>
<h2>Hugging Face Video Uploader</h2>
<div class="form-group">
<label>1. Your Space URL (Direct link)</label>
<input type="text" id="serverUrl" placeholder="https://username-space-name.hf.space" required>
<small style="color: #6b7280; display: block; margin-top: 4px;">Found in Space > Embed this Space > Direct
URL</small>
</div>
<div class="form-group">
<label>2. Video URL (Direct link)</label>
<input type="text" id="videoUrl" placeholder="https://example.com/video.mp4" required>
</div>
<button id="processBtn" onclick="startProcessing()">Process Video</button>
<div class="loader" id="loader">
⏳ Processing on Hugging Face (can take 1-2 mins)...
</div>
<div id="results">
<h3>✅ Processed Chunks</h3>
<div id="linkslist"></div>
</div>
</div>
<script>
async function startProcessing() {
let serverUrl = document.getElementById('serverUrl').value.trim();
serverUrl = serverUrl.replace(/\/$/, ""); // remove trailing slash
const videoUrl = document.getElementById('videoUrl').value.trim();
const btn = document.getElementById('processBtn');
const loader = document.getElementById('loader');
const results = document.getElementById('results');
const linksList = document.getElementById('linkslist');
if (!serverUrl || !videoUrl) {
alert("Please fill in both fields");
return;
}
// UI Reset
btn.disabled = true;
loader.style.display = 'block';
results.style.display = 'none';
linksList.innerHTML = '';
try {
// NOTE: We append /process-video
const response = await fetch(`${serverUrl}/process-video`, {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ video_url: videoUrl })
});
const data = await response.json();
if (data.status === 'success' && data.uploaded_chunks) {
// Display Results
data.uploaded_chunks.forEach((url, index) => {
const div = document.createElement('div');
div.className = 'result-item';
div.innerHTML = `
<span>Part ${index + 1}: <a href="${url}" target="_blank" style="color:#facc15">${url.substring(0, 40)}...</a></span>
<button class="copy-btn" onclick="navigator.clipboard.writeText('${url}')">Copy</button>
`;
linksList.appendChild(div);
});
results.style.display = 'block';
} else {
alert("Error: " + (data.detail || "Unknown error"));
}
} catch (error) {
console.error(error);
alert("Failed to connect. Check URL. If Space is 'Sleeping', this trigger wakes it up, try again in 30s.");
} finally {
btn.disabled = false;
loader.style.display = 'none';
}
}
</script>
</body>
</html>