Spaces:
Runtime error
Runtime error
| <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> | |