Spaces:
Running
Running
| <html> | |
| <head> | |
| <link rel="stylesheet" type="text/css" href="{{ url_for('static', filename='style.css')}}" /> | |
| <!-- <link rel="stylesheet" type="text/css" href="{{ url_for('static', filename='css.css')}}" /> --> | |
| <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script> | |
| </head> | |
| <body> | |
| <div class="row"> | |
| <div class="col-md-10 mr-auto ml-auto"> | |
| <h1> AI-Tiny ChatBot </h1> | |
| <form> | |
| <div id="chatbox"> | |
| <div class="col-md-8 ml-auto mr-auto text-center"> | |
| <p class="botText"><span>Hi! I'm Your bot.</span></p> | |
| </div> | |
| </div> | |
| <div id="userInput" class="row"> | |
| <div class="col-md-10"> | |
| <input id="text" type="text" name="msg" placeholder="Message" class="form-control"> | |
| <button type="submit" id="send" class="btn btn-warning">Send</button> | |
| </div> | |
| </div> | |
| </form> | |
| </div> | |
| </div> | |
| <script> | |
| $(document).ready(function() { | |
| $("form").on("submit", function(event) { | |
| var rawText = $("#text").val(); | |
| var userHtml = '<p class="userText"><span>' + rawText + "</span></p>"; | |
| $("#text").val(""); | |
| $("#chatbox").append(userHtml); | |
| document.getElementById("userInput").scrollIntoView({ | |
| block: "start", | |
| behavior: "smooth", | |
| }); | |
| $.ajax({ | |
| data: { | |
| msg: rawText, | |
| }, | |
| type: "POST", | |
| url: "/get", | |
| }).done(function(data) { | |
| var botHtml = '<p class="botText"><span>' + data + "</span></p>"; | |
| $("#chatbox").append($.parseHTML(botHtml)); | |
| document.getElementById("userInput").scrollIntoView({ | |
| block: "start", | |
| behavior: "smooth", | |
| }); | |
| }); | |
| event.preventDefault(); | |
| }); | |
| }); | |
| </script> | |
| </body> | |
| </html> |