Base WEB UI Funtion
This commit is contained in:
@@ -0,0 +1,23 @@
|
||||
body {
|
||||
background: #111;
|
||||
color: white;
|
||||
font-family: Arial;
|
||||
}
|
||||
|
||||
#chat-container {
|
||||
width: 800px;
|
||||
margin: auto;
|
||||
margin-top: 40px;
|
||||
}
|
||||
|
||||
#messages {
|
||||
height: 500px;
|
||||
border: 1px solid #333;
|
||||
overflow-y: scroll;
|
||||
padding: 10px;
|
||||
}
|
||||
|
||||
#input-area {
|
||||
display: flex;
|
||||
margin-top: 10px;
|
||||
}
|
||||
@@ -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