Spaces:
Runtime error
Runtime error
Upload index.html
Browse files- static/index.html +39 -0
static/index.html
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<!DOCTYPE html>
|
| 2 |
+
<html lang="en">
|
| 3 |
+
<head>
|
| 4 |
+
<meta charset="UTF-8">
|
| 5 |
+
<title>Tiny Chatbot (static page)</title>
|
| 6 |
+
<style>
|
| 7 |
+
body{font-family:system-ui, sans-serif; max-width:42rem; margin:auto; padding:2rem}
|
| 8 |
+
textarea{width:100%; height:8rem}
|
| 9 |
+
button{margin-top:.5rem; padding:.4rem 1rem; font-size:1rem}
|
| 10 |
+
pre{white-space:pre-wrap; background:#f7f7f7; padding:1rem; border-radius:.4rem}
|
| 11 |
+
</style>
|
| 12 |
+
</head>
|
| 13 |
+
<body>
|
| 14 |
+
<h2>Tiny Chatbot test page</h2>
|
| 15 |
+
<textarea id="prompt" placeholder="Paste or type your prompt…"></textarea>
|
| 16 |
+
<button id="send">Send</button>
|
| 17 |
+
<pre id="answer"></pre>
|
| 18 |
+
|
| 19 |
+
<script>
|
| 20 |
+
document.getElementById('send').onclick = async () => {
|
| 21 |
+
const prompt = document.getElementById('prompt').value.trim();
|
| 22 |
+
if (!prompt) return;
|
| 23 |
+
const ansBox = document.getElementById('answer');
|
| 24 |
+
ansBox.textContent = "⏳ thinking…";
|
| 25 |
+
try {
|
| 26 |
+
const r = await fetch('/api/generate', {
|
| 27 |
+
method: 'POST',
|
| 28 |
+
headers: {'Content-Type':'application/json'},
|
| 29 |
+
body: JSON.stringify({prompt})
|
| 30 |
+
});
|
| 31 |
+
const data = await r.json();
|
| 32 |
+
ansBox.textContent = data.response || "(no response)";
|
| 33 |
+
} catch (e) {
|
| 34 |
+
ansBox.textContent = "⚠️ error: "+e;
|
| 35 |
+
}
|
| 36 |
+
};
|
| 37 |
+
</script>
|
| 38 |
+
</body>
|
| 39 |
+
</html>
|