Ken Sang Tang commited on
Commit
391511e
·
verified ·
1 Parent(s): 2cc4f85

Create templates/index.html

Browse files
Files changed (1) hide show
  1. templates/index.html +57 -0
templates/index.html ADDED
@@ -0,0 +1,57 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>Welcome to OpenManus3</title>
5
+ <style>
6
+ body { font-family: sans-serif; padding: 2rem; }
7
+ #output { white-space: pre-wrap; background: #f8f8f8; border: 1px solid #ccc; padding: 1rem; margin-top: 1rem; }
8
+ </style>
9
+ </head>
10
+ <body>
11
+ <h2>Welcome to OpenManus3</h2>
12
+ <input type="text" id="prompt" placeholder="Enter your prompt" style="width: 300px;">
13
+ <button onclick="submitPrompt()">Submit</button>
14
+
15
+ <div id="output">Waiting...</div>
16
+
17
+ <script>
18
+ async function submitPrompt() {
19
+ const prompt = document.getElementById("prompt").value;
20
+ const output = document.getElementById("output");
21
+ output.textContent = "Submitting task...\n";
22
+ try {
23
+ const res = await fetch("/tasks", {
24
+ method: "POST",
25
+ headers: { "Content-Type": "application/json" },
26
+ body: JSON.stringify({ prompt })
27
+ });
28
+ const data = await res.json();
29
+ const taskId = data.task_id;
30
+
31
+ output.textContent += `Task ID: ${taskId}\nListening for events...\n\n`;
32
+ const eventSource = new EventSource(`/tasks/${taskId}/events`);
33
+ eventSource.onmessage = (event) => {
34
+ try {
35
+ const parsed = JSON.parse(event.data);
36
+ output.textContent += `Event: ${event.type}\n${JSON.stringify(parsed, null, 2)}\n\n`;
37
+ } catch (err) {
38
+ output.textContent += `Malformed message: ${event.data}\n`;
39
+ }
40
+ };
41
+ eventSource.onerror = (err) => {
42
+ output.textContent += "[Connection closed]\n";
43
+ eventSource.close();
44
+ };
45
+ } catch (err) {
46
+ output.textContent = `Error submitting task: ${err}`;
47
+ }
48
+ }
49
+ </script>
50
+ </head>
51
+ <body>
52
+ <h1>Welcome to OpenManus3</h1>
53
+ <input type="text" id="prompt" placeholder="Enter your prompt" style="width:300px;">
54
+ <button onclick="submitPrompt()">Submit</button>
55
+ <pre id="output"></pre>
56
+ </body>
57
+ </html>