Base WEB UI Funtion
This commit is contained in:
@@ -0,0 +1,27 @@
|
||||
const sendBtn = document.getElementById("send-btn");
|
||||
|
||||
sendBtn.addEventListener("click", async () => {
|
||||
|
||||
const input = document.getElementById("user-input");
|
||||
const text = input.value;
|
||||
|
||||
const messages = document.getElementById("messages");
|
||||
|
||||
messages.innerHTML += `<p><b>You:</b> ${text}</p>`;
|
||||
|
||||
const response = await fetch("/chat", {
|
||||
method: "POST",
|
||||
headers: {
|
||||
"Content-Type": "application/json"
|
||||
},
|
||||
body: JSON.stringify({
|
||||
message: text
|
||||
})
|
||||
});
|
||||
|
||||
const data = await response.json();
|
||||
|
||||
messages.innerHTML += `<p><b>AI:</b> ${data.response}</p>`;
|
||||
|
||||
input.value = "";
|
||||
});
|
||||
Reference in New Issue
Block a user