Spaces:
Runtime error
Runtime error
Create index.html
Browse files- index.html +85 -0
index.html
ADDED
@@ -0,0 +1,85 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 with AI</title>
|
7 |
+
<style>
|
8 |
+
body {
|
9 |
+
font-family: Arial, sans-serif;
|
10 |
+
margin: 0;
|
11 |
+
padding: 0;
|
12 |
+
background-color: #f4f4f4;
|
13 |
+
display: flex;
|
14 |
+
flex-direction: column;
|
15 |
+
justify-content: center;
|
16 |
+
align-items: center;
|
17 |
+
height: 100vh;
|
18 |
+
}
|
19 |
+
#chatbox {
|
20 |
+
width: 80%;
|
21 |
+
max-width: 500px;
|
22 |
+
background: #fff;
|
23 |
+
padding: 20px;
|
24 |
+
border-radius: 10px;
|
25 |
+
box-shadow: 0 4px 10px rgba(0, 0, 0, 0.2);
|
26 |
+
}
|
27 |
+
#messages {
|
28 |
+
height: 300px;
|
29 |
+
overflow-y: auto;
|
30 |
+
margin-bottom: 20px;
|
31 |
+
border: 1px solid #ddd;
|
32 |
+
padding: 10px;
|
33 |
+
border-radius: 5px;
|
34 |
+
background: #f9f9f9;
|
35 |
+
}
|
36 |
+
#input-box {
|
37 |
+
display: flex;
|
38 |
+
}
|
39 |
+
input[type="text"] {
|
40 |
+
flex: 1;
|
41 |
+
padding: 10px;
|
42 |
+
border: 1px solid #ddd;
|
43 |
+
border-radius: 5px 0 0 5px;
|
44 |
+
outline: none;
|
45 |
+
}
|
46 |
+
button {
|
47 |
+
padding: 10px;
|
48 |
+
border: none;
|
49 |
+
background-color: #007bff;
|
50 |
+
color: white;
|
51 |
+
border-radius: 0 5px 5px 0;
|
52 |
+
cursor: pointer;
|
53 |
+
}
|
54 |
+
button:hover {
|
55 |
+
background-color: #0056b3;
|
56 |
+
}
|
57 |
+
</style>
|
58 |
+
</head>
|
59 |
+
<body>
|
60 |
+
<div id="chatbox">
|
61 |
+
<div id="messages"></div>
|
62 |
+
<div id="input-box">
|
63 |
+
<input id="userInput" type="text" placeholder="Type your message here...">
|
64 |
+
<button onclick="sendMessage()">Send</button>
|
65 |
+
</div>
|
66 |
+
</div>
|
67 |
+
|
68 |
+
<script>
|
69 |
+
async function sendMessage() {
|
70 |
+
const userInput = document.getElementById('userInput').value;
|
71 |
+
if (!userInput) return;
|
72 |
+
|
73 |
+
const messagesDiv = document.getElementById('messages');
|
74 |
+
messagesDiv.innerHTML += `<div><strong>You:</strong> ${userInput}</div>`;
|
75 |
+
|
76 |
+
const response = await fetch(`/get?msg=${encodeURIComponent(userInput)}`);
|
77 |
+
const botResponse = await response.text();
|
78 |
+
messagesDiv.innerHTML += `<div><strong>Bot:</strong> ${botResponse}</div>`;
|
79 |
+
|
80 |
+
document.getElementById('userInput').value = '';
|
81 |
+
messagesDiv.scrollTop = messagesDiv.scrollHeight;
|
82 |
+
}
|
83 |
+
</script>
|
84 |
+
</body>
|
85 |
+
</html>
|