Spaces:
Sleeping
Sleeping
| <!-- templates/index.html --> | |
| <html> | |
| <head> | |
| <title>Welcome to OpenManus3</title> | |
| <style> | |
| body { font-family: sans-serif; padding: 2rem; } | |
| #output { white-space: pre-wrap; background: #f8f8f8; border: 1px solid #ccc; padding: 1rem; margin-top: 1rem; } | |
| </style> | |
| </head> | |
| <body> | |
| <h2>Welcome to OpenManus3</h2> | |
| <input type="text" id="prompt" placeholder="Enter your prompt" style="width: 300px;"> | |
| <button onclick="submitPrompt()">Submit</button> | |
| <div id="output">Waiting...</div> | |
| <script> | |
| async function submitPrompt() { | |
| const prompt = document.getElementById("prompt").value; | |
| const output = document.getElementById("output"); | |
| output.textContent = "Submitting task...\n"; | |
| try { | |
| const res = await fetch("/tasks", { | |
| method: "POST", | |
| headers: { "Content-Type": "application/json" }, | |
| body: JSON.stringify({ prompt }) | |
| }); | |
| const data = await res.json(); | |
| const taskId = data.task_id; | |
| output.textContent += `Task ID: ${taskId}\nListening for events...\n\n`; | |
| const eventSource = new EventSource(`/tasks/${taskId}/events`); | |
| eventSource.onmessage = (event) => { | |
| try { | |
| const parsed = JSON.parse(event.data); | |
| output.textContent += `Event: ${event.type}\n${JSON.stringify(parsed, null, 2)}\n\n`; | |
| } catch (err) { | |
| output.textContent += `Malformed message: ${event.data}\n`; | |
| } | |
| }; | |
| eventSource.onerror = (err) => { | |
| output.textContent += "[Connection closed]\n"; | |
| eventSource.close(); | |
| }; | |
| } catch (err) { | |
| output.textContent = `Error submitting task: ${err}`; | |
| } | |
| } | |
| </script> | |
| </head> | |
| <body> | |
| <h1>Welcome to OpenManus3</h1> | |
| <input type="text" id="prompt" placeholder="Enter your prompt" style="width:300px;"> | |
| <button onclick="submitPrompt()">Submit</button> | |
| <pre id="output"></pre> | |
| </body> | |
| </html> | |