-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest.html
More file actions
238 lines (214 loc) · 7.47 KB
/
test.html
File metadata and controls
238 lines (214 loc) · 7.47 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Comfy Workflows API Test</title>
<style>
* { margin: 0; padding: 0; box-sizing: border-box; }
body {
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
min-height: 100vh;
padding: 20px;
}
.container {
max-width: 1200px;
margin: 0 auto;
background: white;
border-radius: 12px;
box-shadow: 0 20px 60px rgba(0,0,0,0.3);
padding: 30px;
}
h1 { color: #333; margin-bottom: 10px; }
.subtitle { color: #666; margin-bottom: 30px; }
.section {
margin-bottom: 30px;
padding: 20px;
background: #f8f9fa;
border-radius: 8px;
}
.section h2 { color: #555; margin-bottom: 15px; font-size: 18px; }
input, textarea, button {
width: 100%;
padding: 12px;
margin-bottom: 10px;
border: 1px solid #ddd;
border-radius: 6px;
font-size: 14px;
}
textarea { min-height: 100px; font-family: 'Courier New', monospace; }
button {
background: #667eea;
color: white;
border: none;
cursor: pointer;
font-weight: 600;
transition: background 0.2s;
}
button:hover { background: #5568d3; }
button:disabled { background: #ccc; cursor: not-allowed; }
.workflow-item {
background: white;
padding: 15px;
margin-bottom: 10px;
border-radius: 6px;
border-left: 4px solid #667eea;
}
.workflow-item h3 { color: #333; margin-bottom: 5px; font-size: 16px; }
.workflow-item .meta { color: #888; font-size: 12px; margin-bottom: 8px; }
.workflow-item .actions {
display: flex;
gap: 8px;
margin-top: 10px;
}
.workflow-item button {
width: auto;
padding: 6px 12px;
font-size: 12px;
margin: 0;
}
.btn-delete { background: #e74c3c; }
.btn-delete:hover { background: #c0392b; }
.prompts {
background: #f1f1f1;
padding: 8px;
border-radius: 4px;
font-family: monospace;
font-size: 12px;
word-break: break-all;
max-height: 100px;
overflow-y: auto;
}
.status {
padding: 8px 12px;
border-radius: 4px;
margin-bottom: 15px;
font-size: 13px;
}
.status.success { background: #d4edda; color: #155724; border: 1px solid #c3e6cb; }
.status.error { background: #f8d7da; color: #721c24; border: 1px solid #f5c6cb; }
</style>
</head>
<body>
<div class="container">
<h1>🎨 Comfy Workflows API Test</h1>
<p class="subtitle">Test your ComfyUI workflows API</p>
<div class="section">
<h2>⚙️ Configuration</h2>
<input type="text" id="apiUrl" placeholder="API URL (e.g., http://localhost:8787)" value="http://localhost:8787">
<input type="password" id="adminKey" placeholder="Admin API Key (for POST/PUT/DELETE)">
</div>
<div class="section">
<h2>➕ Create Workflow</h2>
<input type="text" id="newName" placeholder="Workflow name">
<textarea id="newPrompts" placeholder='{"prompt": "your workflow json here"}'></textarea>
<input type="text" id="newAuthor" placeholder="Author (optional)">
<input type="text" id="newTags" placeholder="Tags (comma-separated, optional)">
<button onclick="createWorkflow()">Create Workflow</button>
</div>
<div class="section">
<h2>📋 All Workflows</h2>
<button onclick="loadWorkflows()">Refresh List</button>
<div id="workflowList"></div>
</div>
<div id="statusBox"></div>
</div>
<script>
function getHeaders(includeAuth = false) {
const headers = { 'Content-Type': 'application/json' }
if (includeAuth) {
const key = document.getElementById('adminKey').value
if (key) headers['Authorization'] = `Bearer ${key}`
}
return headers
}
function showStatus(message, isError = false) {
const box = document.getElementById('statusBox')
box.innerHTML = `<div class="status ${isError ? 'error' : 'success'}">${message}</div>`
setTimeout(() => box.innerHTML = '', 5000)
}
async function loadWorkflows() {
try {
const url = document.getElementById('apiUrl').value
const res = await fetch(`${url}/workflows`)
const data = await res.json()
const list = document.getElementById('workflowList')
if (data.length === 0) {
list.innerHTML = '<p style="color: #999; padding: 20px;">No workflows yet</p>'
return
}
list.innerHTML = data.map(w => `
<div class="workflow-item">
<h3>${escapeHtml(w.name)}</h3>
<div class="meta">
ID: ${w.id} |
Created: ${new Date(w.createdAt).toLocaleString()} |
${w.author ? `Author: ${escapeHtml(w.author)}` : ''}
</div>
${w.tags && w.tags.length ? `<div class="meta">Tags: ${w.tags.join(', ')}</div>` : ''}
<div class="prompts">${escapeHtml(w.prompts.substring(0, 200))}${w.prompts.length > 200 ? '...' : ''}</div>
<div class="actions">
<button onclick="deleteWorkflow('${w.id}')">Delete</button>
</div>
</div>
`).join('')
showStatus(`Loaded ${data.length} workflows`)
} catch (err) {
showStatus(`Error: ${err.message}`, true)
}
}
async function createWorkflow() {
try {
const url = document.getElementById('apiUrl').value
const name = document.getElementById('newName').value
const prompts = document.getElementById('newPrompts').value
const author = document.getElementById('newAuthor').value
const tags = document.getElementById('newTags').value.split(',').map(t => t.trim()).filter(Boolean)
if (!name || !prompts) {
showStatus('Name and prompts are required', true)
return
}
const res = await fetch(`${url}/workflows`, {
method: 'POST',
headers: getHeaders(true),
body: JSON.stringify({ name, prompts, author, tags })
})
if (!res.ok) throw new Error(`HTTP ${res.status}`)
const data = await res.json()
showStatus(`Created workflow: ${data.name}`)
// Clear form
document.getElementById('newName').value = ''
document.getElementById('newPrompts').value = ''
document.getElementById('newAuthor').value = ''
document.getElementById('newTags').value = ''
loadWorkflows()
} catch (err) {
showStatus(`Error: ${err.message}`, true)
}
}
async function deleteWorkflow(id) {
if (!confirm('Are you sure you want to delete this workflow?')) return
try {
const url = document.getElementById('apiUrl').value
const res = await fetch(`${url}/workflows/${id}`, {
method: 'DELETE',
headers: getHeaders(true)
})
if (!res.ok) throw new Error(`HTTP ${res.status}`)
showStatus(`Deleted workflow ${id}`)
loadWorkflows()
} catch (err) {
showStatus(`Error: ${err.message}`, true)
}
}
function escapeHtml(text) {
const div = document.createElement('div')
div.textContent = text
return div.innerHTML
}
// Load workflows on page load
loadWorkflows()
</script>
</body>
</html>