Spaces:
Runtime error
Runtime error
File size: 1,499 Bytes
4276167 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 | <!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>FAQ Chatbot</title>
<style>
/* Basic styles for the chatbot */
#chatbot {
width: 300px;
border: 1px solid #ddd;
padding: 10px;
margin: 20px;
}
#chatbox {
height: 300px;
overflow-y: auto;
margin-bottom: 10px;
}
#user_input {
width: 100%;
padding: 10px;
}
</style>
</head>
<body>
<div id="chatbot">
<div id="chatbox"></div>
<input type="text" id="user_input" placeholder="Ask a question..." />
<button onclick="sendQuestion()">Send</button>
</div>
<script>
function sendQuestion() {
const question = document.getElementById("user_input").value;
fetch('http://localhost:5000/ask', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ 'question': question })
})
.then(response => response.json())
.then(data => {
const chatbox = document.getElementById("chatbox");
chatbox.innerHTML += "<div>User: " + question + "</div>";
chatbox.innerHTML += "<div>Bot: " + data.answer + "</div>";
});
}
</script>
</body>
</html>
|