Spaces:
Sleeping
Sleeping
Download templates/index2.html from ehsanhon/async_chatbot: direct link, hf CLI and curl.
- Browser
- Download file 1.44 kB
-
https://huggingface.co/spaces/ehsanhon/async_chatbot/resolve/main/templates/index2.html
- Command line
-
hf download hf://spaces/ehsanhon/async_chatbot/templates/index2.html
-
curl -L -o index2.html https://huggingface.co/spaces/ehsanhon/async_chatbot/resolve/main/templates/index2.html
1.44 kB
| <html> | |
| <head> | |
| <title>Async Chatbot</title> | |
| <script src="/static/script2.js" defer></script> | |
| <!-- <script > | |
| async function sendMessage() { | |
| const inputEl = document.getElementById("userInput"); | |
| const statusEl = document.getElementById("status"); | |
| const replyEl = document.getElementById("botReply"); | |
| const message = inputEl.value.trim(); | |
| if (!message) return; | |
| // Update status | |
| statusEl.innerText = "Connecting to service..."; | |
| await delay(300); | |
| statusEl.innerText = "Getting data..."; | |
| const response = await fetch("/chat", { | |
| method: "POST", | |
| headers: { "Content-Type": "application/json" }, | |
| body: JSON.stringify({ message }) | |
| }); | |
| const data = await response.json(); | |
| statusEl.innerText = "Operation complete."; | |
| replyEl.innerText = data.reply; | |
| } | |
| function delay(ms) { | |
| return new Promise(resolve => setTimeout(resolve, ms)); | |
| } | |
| </script> --> | |
| </head> | |
| <body> | |
| <h2>Talk to the Bot</h2> | |
| <input type="text" id="userInput" placeholder="Say something..." /> | |
| <button onclick="sendMessage()">Send</button> | |
| <p><strong>Status:</strong> <span id="status">Idle</span></p> | |
| <p><strong>Bot:</strong> <span id="botReply"></span></p> | |
| </body> | |
| </html> | |