Base WEB UI Funtion

This commit is contained in:
2026-05-12 19:20:46 +03:00
parent e9a843bdc8
commit 47a704e152
4 changed files with 73 additions and 20 deletions
+23
View File
@@ -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;
}
+27
View File
@@ -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 = "";
});