Spaces:
Runtime error
Runtime error
Create index.html
Browse files- index.html +77 -0
index.html
ADDED
|
@@ -0,0 +1,77 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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>Chat Interface</title>
|
| 7 |
+
<style>
|
| 8 |
+
body {
|
| 9 |
+
font-family: Arial, sans-serif;
|
| 10 |
+
}
|
| 11 |
+
.chat-container {
|
| 12 |
+
width: 500px;
|
| 13 |
+
margin: 0 auto;
|
| 14 |
+
padding: 20px;
|
| 15 |
+
border: 1px solid #ccc;
|
| 16 |
+
border-radius: 10px;
|
| 17 |
+
}
|
| 18 |
+
.chat-box {
|
| 19 |
+
width: 100%;
|
| 20 |
+
height: 300px;
|
| 21 |
+
border: 1px solid #ccc;
|
| 22 |
+
border-radius: 10px;
|
| 23 |
+
padding: 10px;
|
| 24 |
+
overflow-y: scroll;
|
| 25 |
+
}
|
| 26 |
+
.chat-input {
|
| 27 |
+
width: 100%;
|
| 28 |
+
padding: 10px;
|
| 29 |
+
margin-top: 10px;
|
| 30 |
+
border: 1px solid #ccc;
|
| 31 |
+
border-radius: 10px;
|
| 32 |
+
}
|
| 33 |
+
.chat-button {
|
| 34 |
+
width: 100%;
|
| 35 |
+
padding: 10px;
|
| 36 |
+
margin-top: 10px;
|
| 37 |
+
background-color: #007BFF;
|
| 38 |
+
color: white;
|
| 39 |
+
border: none;
|
| 40 |
+
border-radius: 10px;
|
| 41 |
+
cursor: pointer;
|
| 42 |
+
}
|
| 43 |
+
</style>
|
| 44 |
+
</head>
|
| 45 |
+
<body>
|
| 46 |
+
<div class="chat-container">
|
| 47 |
+
<div class="chat-box" id="chat-box"></div>
|
| 48 |
+
<input type="text" class="chat-input" id="chat-input" placeholder="Type your message here...">
|
| 49 |
+
<button class="chat-button" onclick="sendMessage()">Send</button>
|
| 50 |
+
</div>
|
| 51 |
+
|
| 52 |
+
<script>
|
| 53 |
+
async function sendMessage() {
|
| 54 |
+
const input = document.getElementById('chat-input');
|
| 55 |
+
const message = input.value;
|
| 56 |
+
if (message.trim() === '') return;
|
| 57 |
+
|
| 58 |
+
const chatBox = document.getElementById('chat-box');
|
| 59 |
+
chatBox.innerHTML += `<div><strong>You:</strong> ${message}</div>`;
|
| 60 |
+
|
| 61 |
+
input.value = '';
|
| 62 |
+
|
| 63 |
+
const response = await fetch('/chat', {
|
| 64 |
+
method: 'POST',
|
| 65 |
+
headers: {
|
| 66 |
+
'Content-Type': 'application/json'
|
| 67 |
+
},
|
| 68 |
+
body: JSON.stringify({ query: message })
|
| 69 |
+
});
|
| 70 |
+
|
| 71 |
+
const data = await response.json();
|
| 72 |
+
chatBox.innerHTML += `<div><strong>Bot:</strong> ${data.response}</div>`;
|
| 73 |
+
chatBox.scrollTop = chatBox.scrollHeight;
|
| 74 |
+
}
|
| 75 |
+
</script>
|
| 76 |
+
</body>
|
| 77 |
+
</html>
|