File size: 1,272 Bytes
0f5cb28
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <title>Tiny Chatbot (static page)</title>
  <style>
    body{font-family:system-ui, sans-serif; max-width:42rem; margin:auto; padding:2rem}
    textarea{width:100%; height:8rem}
    button{margin-top:.5rem; padding:.4rem 1rem; font-size:1rem}
    pre{white-space:pre-wrap; background:#f7f7f7; padding:1rem; border-radius:.4rem}
  </style>
</head>
<body>
  <h2>Tiny Chatbot test page</h2>
  <textarea id="prompt" placeholder="Paste or type your prompt…"></textarea>
  <button id="send">Send</button>
  <pre id="answer"></pre>

  <script>
    document.getElementById('send').onclick = async () => {
      const prompt = document.getElementById('prompt').value.trim();
      if (!prompt) return;
      const ansBox = document.getElementById('answer');
      ansBox.textContent = "⏳ thinking…";
      try {
        const r = await fetch('/api/generate', {
          method: 'POST',
          headers: {'Content-Type':'application/json'},
          body: JSON.stringify({prompt})
        });
        const data = await r.json();
        ansBox.textContent = data.response || "(no response)";
      } catch (e) {
        ansBox.textContent = "⚠️ error: "+e;
      }
    };
  </script>
</body>
</html>