-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstyles.html
More file actions
82 lines (81 loc) · 2.65 KB
/
Copy pathstyles.html
File metadata and controls
82 lines (81 loc) · 2.65 KB
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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
<!DOCTYPE html>
<html>
<head>
<title>Question Logger</title>
<style>
body {
font-family: Calibri, sans-serif;
margin: 20px;
}
h1 {
text-align: center;
}
form {
margin-bottom: 20px;
}
label {
display: block;
margin-bottom: 5px;
}
input[type="text"] {
width: calc(100% - 22px);
padding: 10px;
margin-bottom: 10px;
}
input[type="submit"] {
padding: 10px 20px;
background-color: #007BFF;
color: white;
border: none;
cursor: pointer;
}
input[type="submit"]:hover {
background-color: #0056b3;
}
#conversation {
border: 1px solid #ccc;
padding: 10px;
max-height: 800px;
overflow-y: auto;
}
p {
margin: 5px 0;
}
.user-question {
color: darkgreen;
}
</style>
</head>
<body>
<h1>Amin's Bot!</h1>
<form onsubmit="return submitInput()">
<label for="input">Ask a question or enter a response:</label>
<input type="text" id="input" name="input" required>
<input type="submit" value="Submit">
</form>
<div id="conversation"></div>
<script>
function submitInput() {
var input = document.getElementById('input').value;
var conversationDisplay = document.getElementById('conversation');
conversationDisplay.innerHTML += '<p class="user-question">User: ' + input;
fetch('/store_input/', {
method: 'POST',
headers: {
'Content-Type': 'application/x-www-form-urlencoded'
},
body: 'input=' + encodeURIComponent(input)
})
.then(response => response.json())
.then(data => {
console.log(data);
conversationDisplay.innerHTML += '<p>Bot: ' + data.message + '</p><br>';
conversationDisplay.scrollTop = conversationDisplay.scrollHeight;
})
.catch(error => console.error('Error:', error));
document.getElementById('input').value = '';
return false;
}
</script>
</body>
</html>