Noahabebe commited on
Commit
ad96fea
·
1 Parent(s): a4f61a3
Files changed (1) hide show
  1. templates/index.html +65 -0
templates/index.html ADDED
@@ -0,0 +1,65 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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>Find Matching Command</title>
7
+ <script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
8
+ <style>
9
+ #loading {
10
+ display: none;
11
+ }
12
+ </style>
13
+ </head>
14
+ <body>
15
+ <h1>Find Matching Command</h1>
16
+ <form id="commandForm">
17
+ <label for="description">Enter Description:</label><br>
18
+ <textarea id="description" name="description" rows="4" cols="50"></textarea><br>
19
+ <button type="submit">Submit</button>
20
+ </form>
21
+ <div id="loading">Loading...</div>
22
+ <h2>Baymax:</h2>
23
+ <p id="response"></p>
24
+ <p id="command"></p>
25
+ <p id="commandResult"></p>
26
+
27
+ <script>
28
+ $(document).ready(function() {
29
+ $('#commandForm').submit(function(e) {
30
+ e.preventDefault();
31
+ $('#loading').show(); // Show loading message
32
+
33
+ $.ajax({
34
+ type: 'POST',
35
+ url: '/',
36
+ data: $(this).serialize(),
37
+ success: function(response) {
38
+ $('#loading').hide(); // Hide loading message
39
+
40
+ if (response.command) {
41
+ $('#command').text('<strong>Command:</strong> ' + response.command);
42
+ $('#response').html('<strong>Baymax:</strong> ' + response.assistant_response);
43
+ $('#commandResult').html('<strong>Result:</strong> ' + response.result);
44
+ } else if (response.assistant_response) {
45
+ $('#response').html('<strong>Baymax:</strong> ' + response.assistant_response);
46
+ $('#command').text(''); // Clear command if no command
47
+ $('#commandResult').text(''); // Clear command result if no command
48
+ } else {
49
+ $('#response').text('No response received.');
50
+ $('#command').text(''); // Clear command if no response
51
+ $('#commandResult').text(''); // Clear command result if no response
52
+ }
53
+ },
54
+ error: function() {
55
+ $('#loading').hide(); // Hide loading message
56
+ $('#response').text('An error occurred while processing your request.');
57
+ $('#command').text(''); // Clear command if error
58
+ $('#commandResult').text(''); // Clear command result if error
59
+ }
60
+ });
61
+ });
62
+ });
63
+ </script>
64
+ </body>
65
+ </html>