Ken Sang Tang commited on
Commit
2318f43
·
verified ·
1 Parent(s): ed72a12

Update templates/index.html

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