Spaces:
Runtime error
Runtime error
Create templates/index.html
Browse files- templates/index.html +41 -0
templates/index.html
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<!DOCTYPE html>
|
| 2 |
+
<html lang="en">
|
| 3 |
+
<head>
|
| 4 |
+
<meta charset="UTF-8">
|
| 5 |
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
| 6 |
+
<title>Chatbot FAQ</title>
|
| 7 |
+
<link rel="stylesheet" href="{{ url_for('static', filename='style.css') }}">
|
| 8 |
+
</head>
|
| 9 |
+
<body>
|
| 10 |
+
|
| 11 |
+
<div class="chat-container">
|
| 12 |
+
<div id="chat-box" class="chat-box"></div>
|
| 13 |
+
<input type="text" id="user-input" placeholder="Ask a question..." />
|
| 14 |
+
<button id="send-btn">Send</button>
|
| 15 |
+
</div>
|
| 16 |
+
|
| 17 |
+
<script>
|
| 18 |
+
document.getElementById("send-btn").addEventListener("click", function() {
|
| 19 |
+
var userMessage = document.getElementById("user-input").value;
|
| 20 |
+
|
| 21 |
+
// Display user message in chat box
|
| 22 |
+
var chatBox = document.getElementById("chat-box");
|
| 23 |
+
chatBox.innerHTML += "<p><strong>You:</strong> " + userMessage + "</p>";
|
| 24 |
+
|
| 25 |
+
// Send message to backend
|
| 26 |
+
fetch('/chat', {
|
| 27 |
+
method: 'POST',
|
| 28 |
+
body: new URLSearchParams({ 'message': userMessage }),
|
| 29 |
+
headers: { 'Content-Type': 'application/x-www-form-urlencoded' }
|
| 30 |
+
})
|
| 31 |
+
.then(response => response.json())
|
| 32 |
+
.then(data => {
|
| 33 |
+
// Display bot response
|
| 34 |
+
chatBox.innerHTML += "<p><strong>Bot:</strong> " + data.response + "</p>";
|
| 35 |
+
document.getElementById("user-input").value = ''; // Clear input field
|
| 36 |
+
});
|
| 37 |
+
});
|
| 38 |
+
</script>
|
| 39 |
+
|
| 40 |
+
</body>
|
| 41 |
+
</html>
|