Ken Sang Tang commited on
Commit
da92af9
·
verified ·
1 Parent(s): 43c09cf

Update templates/index.html

Browse files
Files changed (1) hide show
  1. templates/index.html +32 -4
templates/index.html CHANGED
@@ -1,10 +1,38 @@
 
1
  <!DOCTYPE html>
2
  <html>
3
  <head>
4
- <title>OpenManus3</title>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
5
  </head>
6
  <body>
7
- <h1>Welcome to OpenManus3</h1>
8
- <p><a href="/chat?theme=openmanus">Start Chat</a></p>
 
 
9
  </body>
10
- </html>
 
1
+ <!-- templates/index.html -->
2
  <!DOCTYPE html>
3
  <html>
4
  <head>
5
+ <title>FastAPI Task Runner</title>
6
+ <script>
7
+ async function submitPrompt() {
8
+ const prompt = document.getElementById("prompt").value;
9
+ const response = await fetch("/tasks", {
10
+ method: "POST",
11
+ headers: { "Content-Type": "application/json" },
12
+ body: JSON.stringify({ prompt })
13
+ });
14
+
15
+ const data = await response.json();
16
+ const taskId = data.task_id;
17
+ document.getElementById("output").textContent = "Task submitted. Waiting for response...";
18
+
19
+ const eventSource = new EventSource(`/tasks/${taskId}/events`);
20
+ eventSource.onmessage = (event) => {
21
+ const parsed = JSON.parse(event.data);
22
+ document.getElementById("output").textContent = JSON.stringify(parsed, null, 2);
23
+ };
24
+
25
+ eventSource.onerror = () => {
26
+ eventSource.close();
27
+ document.getElementById("output").textContent += "\n[Connection closed]";
28
+ };
29
+ }
30
+ </script>
31
  </head>
32
  <body>
33
+ <h1>FastAPI Task Runner</h1>
34
+ <input type="text" id="prompt" placeholder="Enter your prompt" style="width:300px;">
35
+ <button onclick="submitPrompt()">Submit</button>
36
+ <pre id="output"></pre>
37
  </body>
38
+ </html>