Spaces:
Running
Running
Update hub.html
Browse files
hub.html
CHANGED
|
@@ -5,38 +5,26 @@
|
|
| 5 |
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
|
| 6 |
<title>HF Space Commander - AI PRO SUITE</title>
|
| 7 |
|
| 8 |
-
<!-- Using your Master CSS Engine -->
|
| 9 |
<link rel="stylesheet" href="style.css">
|
| 10 |
<link href="https://fonts.googleapis.com/css2?family=Poppins:wght@400;600;800;900&family=JetBrains+Mono:wght@400;700&display=swap" rel="stylesheet">
|
| 11 |
|
| 12 |
<style>
|
| 13 |
-
/* Custom Terminal Styling */
|
| 14 |
.terminal-window {
|
| 15 |
-
background: #0f172a;
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
padding: 20px;
|
| 19 |
-
height: 400px;
|
| 20 |
-
overflow-y: auto;
|
| 21 |
-
font-family: 'JetBrains Mono', monospace;
|
| 22 |
-
color: #38bdf8;
|
| 23 |
-
font-size: 13px;
|
| 24 |
-
box-shadow: 0 10px 30px rgba(0,0,0,0.5);
|
| 25 |
-
box-sizing: border-box;
|
| 26 |
}
|
| 27 |
.terminal-line { margin-bottom: 8px; line-height: 1.5; }
|
| 28 |
.terminal-time { color: #64748b; margin-right: 10px; }
|
| 29 |
.terminal-error { color: #ef4444; }
|
| 30 |
.terminal-success { color: #10b981; }
|
| 31 |
.terminal-warning { color: #f59e0b; }
|
| 32 |
-
|
| 33 |
.hf-input-group { margin-bottom: 20px; }
|
| 34 |
.hf-label { font-size: 12px; font-weight: 800; color: var(--text-muted); text-transform: uppercase; margin-bottom: 8px; display: block; letter-spacing: 1px; }
|
| 35 |
</style>
|
| 36 |
</head>
|
| 37 |
<body>
|
| 38 |
|
| 39 |
-
<!-- TOPBAR -->
|
| 40 |
<div class="topbar">
|
| 41 |
<div class="menuBtn" onclick="window.location.href='index.html'">๐ </div>
|
| 42 |
<div class="appTitle">HF COMMAND CENTER</div>
|
|
@@ -59,7 +47,7 @@
|
|
| 59 |
<h3 style="color: var(--primary); margin-bottom: 20px; font-weight: 900;">โ๏ธ Configuration</h3>
|
| 60 |
|
| 61 |
<div class="hf-input-group">
|
| 62 |
-
<label class="hf-label">Hugging Face
|
| 63 |
<input type="password" id="hfToken" placeholder="hf_xxxxxxxxxxxxxxxxxxxx" style="font-family: monospace;">
|
| 64 |
</div>
|
| 65 |
|
|
@@ -96,6 +84,9 @@
|
|
| 96 |
</div>
|
| 97 |
|
| 98 |
<script>
|
|
|
|
|
|
|
|
|
|
| 99 |
// --- TERMINAL LOGGER ---
|
| 100 |
function logToTerminal(message, type = 'info') {
|
| 101 |
const terminal = document.getElementById('terminalOutput');
|
|
@@ -120,14 +111,15 @@
|
|
| 120 |
}
|
| 121 |
|
| 122 |
function getCredentials() {
|
| 123 |
-
|
|
|
|
| 124 |
const repoId = document.getElementById('hfRepoId').value.trim();
|
| 125 |
|
| 126 |
-
if (!
|
| 127 |
-
logToTerminal('ERROR:
|
| 128 |
return null;
|
| 129 |
}
|
| 130 |
-
return {
|
| 131 |
}
|
| 132 |
|
| 133 |
function updateStatusBadge(status) {
|
|
@@ -149,7 +141,7 @@
|
|
| 149 |
}
|
| 150 |
}
|
| 151 |
|
| 152 |
-
// --- HUGGING FACE API CALLS ---
|
| 153 |
|
| 154 |
// 1. Start or Pause the Space
|
| 155 |
async function executeSpaceAction(action) {
|
|
@@ -162,7 +154,7 @@
|
|
| 162 |
const response = await fetch(`https://huggingface.co/api/spaces/${creds.repoId}/${action}`, {
|
| 163 |
method: 'POST',
|
| 164 |
headers: {
|
| 165 |
-
'Authorization': `Bearer ${
|
| 166 |
'Content-Type': 'application/json'
|
| 167 |
}
|
| 168 |
});
|
|
@@ -178,7 +170,6 @@
|
|
| 178 |
}
|
| 179 |
} catch (err) {
|
| 180 |
logToTerminal(`โ Network Error: ${err.message}`, 'error');
|
| 181 |
-
logToTerminal(`Note: If CORS is blocking this, you may need to route this request through your server.js`, 'error');
|
| 182 |
}
|
| 183 |
}
|
| 184 |
|
|
@@ -193,7 +184,7 @@
|
|
| 193 |
const response = await fetch(`https://huggingface.co/api/spaces/${creds.repoId}`, {
|
| 194 |
method: 'GET',
|
| 195 |
headers: {
|
| 196 |
-
'Authorization': `Bearer ${
|
| 197 |
}
|
| 198 |
});
|
| 199 |
|
|
|
|
| 5 |
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
|
| 6 |
<title>HF Space Commander - AI PRO SUITE</title>
|
| 7 |
|
|
|
|
| 8 |
<link rel="stylesheet" href="style.css">
|
| 9 |
<link href="https://fonts.googleapis.com/css2?family=Poppins:wght@400;600;800;900&family=JetBrains+Mono:wght@400;700&display=swap" rel="stylesheet">
|
| 10 |
|
| 11 |
<style>
|
|
|
|
| 12 |
.terminal-window {
|
| 13 |
+
background: #0f172a; border: 1px solid var(--primary); border-radius: 16px;
|
| 14 |
+
padding: 20px; height: 400px; overflow-y: auto; font-family: 'JetBrains Mono', monospace;
|
| 15 |
+
color: #38bdf8; font-size: 13px; box-shadow: 0 10px 30px rgba(0,0,0,0.5); box-sizing: border-box;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 16 |
}
|
| 17 |
.terminal-line { margin-bottom: 8px; line-height: 1.5; }
|
| 18 |
.terminal-time { color: #64748b; margin-right: 10px; }
|
| 19 |
.terminal-error { color: #ef4444; }
|
| 20 |
.terminal-success { color: #10b981; }
|
| 21 |
.terminal-warning { color: #f59e0b; }
|
|
|
|
| 22 |
.hf-input-group { margin-bottom: 20px; }
|
| 23 |
.hf-label { font-size: 12px; font-weight: 800; color: var(--text-muted); text-transform: uppercase; margin-bottom: 8px; display: block; letter-spacing: 1px; }
|
| 24 |
</style>
|
| 25 |
</head>
|
| 26 |
<body>
|
| 27 |
|
|
|
|
| 28 |
<div class="topbar">
|
| 29 |
<div class="menuBtn" onclick="window.location.href='index.html'">๐ </div>
|
| 30 |
<div class="appTitle">HF COMMAND CENTER</div>
|
|
|
|
| 47 |
<h3 style="color: var(--primary); margin-bottom: 20px; font-weight: 900;">โ๏ธ Configuration</h3>
|
| 48 |
|
| 49 |
<div class="hf-input-group">
|
| 50 |
+
<label class="hf-label">Hugging Face API_TOKEN (Write Access)</label>
|
| 51 |
<input type="password" id="hfToken" placeholder="hf_xxxxxxxxxxxxxxxxxxxx" style="font-family: monospace;">
|
| 52 |
</div>
|
| 53 |
|
|
|
|
| 84 |
</div>
|
| 85 |
|
| 86 |
<script>
|
| 87 |
+
// --- GLOBAL API_TOKEN VARIABLE ---
|
| 88 |
+
let API_TOKEN = "";
|
| 89 |
+
|
| 90 |
// --- TERMINAL LOGGER ---
|
| 91 |
function logToTerminal(message, type = 'info') {
|
| 92 |
const terminal = document.getElementById('terminalOutput');
|
|
|
|
| 111 |
}
|
| 112 |
|
| 113 |
function getCredentials() {
|
| 114 |
+
// Assigning the value strictly to API_TOKEN
|
| 115 |
+
API_TOKEN = document.getElementById('hfToken').value.trim();
|
| 116 |
const repoId = document.getElementById('hfRepoId').value.trim();
|
| 117 |
|
| 118 |
+
if (!API_TOKEN || !repoId) {
|
| 119 |
+
logToTerminal('ERROR: API_TOKEN and Space ID are required!', 'error');
|
| 120 |
return null;
|
| 121 |
}
|
| 122 |
+
return { repoId };
|
| 123 |
}
|
| 124 |
|
| 125 |
function updateStatusBadge(status) {
|
|
|
|
| 141 |
}
|
| 142 |
}
|
| 143 |
|
| 144 |
+
// --- HUGGING FACE API CALLS (USING API_TOKEN) ---
|
| 145 |
|
| 146 |
// 1. Start or Pause the Space
|
| 147 |
async function executeSpaceAction(action) {
|
|
|
|
| 154 |
const response = await fetch(`https://huggingface.co/api/spaces/${creds.repoId}/${action}`, {
|
| 155 |
method: 'POST',
|
| 156 |
headers: {
|
| 157 |
+
'Authorization': `Bearer ${API_TOKEN}`, // <-- STRICTLY USING API_TOKEN
|
| 158 |
'Content-Type': 'application/json'
|
| 159 |
}
|
| 160 |
});
|
|
|
|
| 170 |
}
|
| 171 |
} catch (err) {
|
| 172 |
logToTerminal(`โ Network Error: ${err.message}`, 'error');
|
|
|
|
| 173 |
}
|
| 174 |
}
|
| 175 |
|
|
|
|
| 184 |
const response = await fetch(`https://huggingface.co/api/spaces/${creds.repoId}`, {
|
| 185 |
method: 'GET',
|
| 186 |
headers: {
|
| 187 |
+
'Authorization': `Bearer ${API_TOKEN}` // <-- STRICTLY USING API_TOKEN
|
| 188 |
}
|
| 189 |
});
|
| 190 |
|