forked from avirajdongare/BooleanAutocrats
-
Notifications
You must be signed in to change notification settings - Fork 0
/
AI_chatbot
53 lines (52 loc) · 2.14 KB
/
AI_chatbot
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
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css">
<link rel="stylesheet" href="/static/style.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
</head>
<body>
<h1 class="jumbotron text-center">AI Chatbot with Python</h1>
<div class="container">
<div class="row">
<div class="col-sm-6 offset-sm-3">
<div id="chatbox" class="border border-success">
<p class="botText"><span>Hi! I'm Chatterbot</span></p>
</div>
<div id="userInput">
<input id="textInput" class="form-control" type="text" name="msg" placeholder="Type Your Message Here">
<input id="buttonInput" class="btn btn-success form-control" type="submit" value="Send">
</div>
</div>
</div>
<script>
function getResponse() {
let userText = $("#textInput").val();
let userHtml = '<p class="userText"><span>' + userText + '</span></p>';
$("#textInput").val("");
$("#chatbox").append(userHtml);
document.getElementById('userInput').scrollIntoView({block: 'start', behavior: 'smooth'});
$.get("/get", { msg: userText }).done(function(data) {
var botHtml = '<p class="botText"><span>' + data + '</span></p>';
$("#chatbox").append(botHtml);
document.getElementById('userInput').scrollIntoView({block: 'start', behavior: 'smooth'});
});
}
$("#textInput").keypress(function(e) {
//if enter key is pressed
if(e.which == 13) {
getResponse();
}
});
$("#buttonInput").click(function() {
getResponse();
});
</script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.7/umd/popper.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js"></script>
</div>
</body>
</html>