AkshayaKeerthi commited on
Commit
153179f
1 Parent(s): c6cb92e

Update templates/index.html

Browse files
Files changed (1) hide show
  1. templates/index.html +44 -0
templates/index.html CHANGED
@@ -0,0 +1,44 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <!-- templates/index.html -->
2
+ <!DOCTYPE html>
3
+ <html lang="en">
4
+ <head>
5
+ <meta charset="UTF-8">
6
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
7
+ <title>Chat Interface</title>
8
+ <link rel="stylesheet" href="{{ url_for('static', filename='styles.css') }}">
9
+ <script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
10
+ </head>
11
+ <body>
12
+ <div class="chat-container">
13
+ <div id="chat-box" class="chat-box"></div>
14
+ <form id="chat-form">
15
+ <input id="user-input" type="text" placeholder="Type a message" required>
16
+ <button type="submit">Send</button>
17
+ </form>
18
+ </div>
19
+
20
+ <script>
21
+ $(document).ready(function(){
22
+ $('#chat-form').on('submit', function(event){
23
+ event.preventDefault();
24
+ const userMessage = $('#user-input').val();
25
+ if(userMessage.trim() === "") return;
26
+
27
+ $('#chat-box').append('<div class="message sent">' + userMessage + '</div>');
28
+ $('#user-input').val('');
29
+
30
+ $.ajax({
31
+ url: '/predict',
32
+ type: 'POST',
33
+ contentType: 'application/json',
34
+ data: JSON.stringify({ message: userMessage }),
35
+ success: function(response){
36
+ $('#chat-box').append('<div class="message received">' + response.response + '</div>');
37
+ $('#chat-box').scrollTop($('#chat-box')[0].scrollHeight);
38
+ }
39
+ });
40
+ });
41
+ });
42
+ </script>
43
+ </body>
44
+ </html>