Spaces:
Runtime error
Runtime error
Commit ·
8ef541c
1
Parent(s): 11e4610
Update templates/index.html
Browse files- templates/index.html +153 -117
templates/index.html
CHANGED
|
@@ -1,125 +1,161 @@
|
|
| 1 |
<!DOCTYPE html>
|
| 2 |
<html>
|
| 3 |
<head>
|
| 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 |
</head>
|
| 66 |
|
| 67 |
<body>
|
| 68 |
-
|
| 69 |
-
|
| 70 |
-
|
| 71 |
-
|
| 72 |
-
|
| 73 |
-
|
| 74 |
-
|
| 75 |
-
|
| 76 |
-
|
| 77 |
-
|
| 78 |
-
|
| 79 |
-
|
| 80 |
-
|
| 81 |
-
|
| 82 |
-
|
| 83 |
-
|
| 84 |
-
|
| 85 |
-
|
| 86 |
-
|
| 87 |
-
|
| 88 |
-
|
| 89 |
-
|
| 90 |
-
|
| 91 |
-
|
| 92 |
-
|
| 93 |
-
|
| 94 |
-
|
| 95 |
-
|
| 96 |
-
|
| 97 |
-
|
| 98 |
-
|
| 99 |
-
|
| 100 |
-
|
| 101 |
-
|
| 102 |
-
|
| 103 |
-
|
| 104 |
-
|
| 105 |
-
|
| 106 |
-
|
| 107 |
-
|
| 108 |
-
|
| 109 |
-
|
| 110 |
-
|
| 111 |
-
|
| 112 |
-
|
| 113 |
-
|
| 114 |
-
|
| 115 |
-
|
| 116 |
-
|
| 117 |
-
|
| 118 |
-
|
| 119 |
-
|
| 120 |
-
|
| 121 |
-
|
| 122 |
-
|
| 123 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 124 |
</body>
|
| 125 |
</html>
|
|
|
|
| 1 |
<!DOCTYPE html>
|
| 2 |
<html>
|
| 3 |
<head>
|
| 4 |
+
<style>
|
| 5 |
+
form {
|
| 6 |
+
background-image: url("img_tree.png");
|
| 7 |
+
background-repeat: no-repeat;
|
| 8 |
+
background-position: 90% 40%;
|
| 9 |
+
margin-right: 10px;
|
| 10 |
+
}
|
| 11 |
+
|
| 12 |
+
fieldset {
|
| 13 |
+
font-size: 12px;
|
| 14 |
+
max-width: 900px; /* Set max width to control the form width */
|
| 15 |
+
margin: auto; /* Center the form */
|
| 16 |
+
}
|
| 17 |
+
|
| 18 |
+
legend {
|
| 19 |
+
background-color: #fff;
|
| 20 |
+
color: #000;
|
| 21 |
+
padding: 0.5px;
|
| 22 |
+
}
|
| 23 |
+
|
| 24 |
+
select {
|
| 25 |
+
padding: 1px;
|
| 26 |
+
font-size: 16px;
|
| 27 |
+
border-radius: 5px;
|
| 28 |
+
border: 1px solid #ccc;
|
| 29 |
+
width: 10%; /* Make the select box full width */
|
| 30 |
+
}
|
| 31 |
+
|
| 32 |
+
input[type="submit"] {
|
| 33 |
+
padding: 10px 20px;
|
| 34 |
+
font-size: 16px;
|
| 35 |
+
border-radius: 5px;
|
| 36 |
+
border: none;
|
| 37 |
+
background-color: #76D7C8;
|
| 38 |
+
color: black;
|
| 39 |
+
cursor: pointer;
|
| 40 |
+
transition: background-color 0.3s;
|
| 41 |
+
}
|
| 42 |
+
|
| 43 |
+
input[type="submit"]:hover {
|
| 44 |
+
background-color: #808081; /* Darken the background on hover */
|
| 45 |
+
}
|
| 46 |
+
|
| 47 |
+
textarea {
|
| 48 |
+
font-size: 1rem;
|
| 49 |
+
letter-spacing: 1px;
|
| 50 |
+
padding: 10px;
|
| 51 |
+
max-width: 80%;
|
| 52 |
+
|
| 53 |
+
width: 100%; /* Make the textarea full width */
|
| 54 |
+
|
| 55 |
+
min-height: 10px;
|
| 56 |
+
|
| 57 |
+
line-height: 1.5;
|
| 58 |
+
border-radius: 20px;
|
| 59 |
+
border: 5px solid #ccc;
|
| 60 |
+
box-shadow: 10px 10px 10px #999;
|
| 61 |
+
margin-bottom: 10px; /* Add some space between textarea and button */
|
| 62 |
+
}
|
| 63 |
+
|
| 64 |
+
/* Add new CSS for message display */
|
| 65 |
+
.messages {
|
| 66 |
+
max-height: 200px;
|
| 67 |
+
overflow-y: auto;
|
| 68 |
+
border: 1px solid #ccc;
|
| 69 |
+
padding: 10px;
|
| 70 |
+
background-color: #f9f9f9;
|
| 71 |
+
margin-bottom: 10px;
|
| 72 |
+
}
|
| 73 |
+
|
| 74 |
+
.message {
|
| 75 |
+
margin-bottom: 10px;
|
| 76 |
+
}
|
| 77 |
+
|
| 78 |
+
.user-message {
|
| 79 |
+
background-color: #fff;
|
| 80 |
+
padding: 5px 10px;
|
| 81 |
+
border-radius: 10px;
|
| 82 |
+
border: 1px solid #ccc;
|
| 83 |
+
margin-right: 50%;
|
| 84 |
+
word-wrap: break-word;
|
| 85 |
+
}
|
| 86 |
+
|
| 87 |
+
.bot-message {
|
| 88 |
+
background-color: #76D7C8;
|
| 89 |
+
color: black;
|
| 90 |
+
padding: 5px 10px;
|
| 91 |
+
border-radius: 10px;
|
| 92 |
+
border: 1px solid #ccc;
|
| 93 |
+
margin-left: 50%;
|
| 94 |
+
word-wrap: break-word;
|
| 95 |
+
}
|
| 96 |
+
</style>
|
| 97 |
</head>
|
| 98 |
|
| 99 |
<body>
|
| 100 |
+
<form action="{{url_for('predict')}}" method="Post" onsubmit="clearTextArea(event)">
|
| 101 |
+
<fieldset>
|
| 102 |
+
<legend><h2 style="font-size: 20px;">Custom Chatbot Demo </h2></legend>
|
| 103 |
+
|
| 104 |
+
<strong><p style="font-family: 'Fantasy', monospace; font-size: 20px; color: grey;">demo NLP chatbot models trained for few conversation </p></strong>
|
| 105 |
+
<strong><b>let's start with "hello" or "help"<b></strong>
|
| 106 |
+
<br>
|
| 107 |
+
<br>
|
| 108 |
+
<div class="messages" id="messages"></div>
|
| 109 |
+
<textarea id="textarea" name="textarea" required='required'></textarea>
|
| 110 |
+
<br>
|
| 111 |
+
<input type="submit" value="Enter" id="submit-button"> <br><br>
|
| 112 |
+
</fieldset>
|
| 113 |
+
</form>
|
| 114 |
+
|
| 115 |
+
<script>
|
| 116 |
+
document.getElementById("textarea").addEventListener("keydown", function(event) {
|
| 117 |
+
if (event.key === "Enter" && !event.shiftKey) {
|
| 118 |
+
event.preventDefault(); // Prevent the default "Enter" behavior (new line)
|
| 119 |
+
document.getElementById("submit-button").click(); // Trigger the submit button click
|
| 120 |
+
}
|
| 121 |
+
});
|
| 122 |
+
|
| 123 |
+
function clearTextArea(event) {
|
| 124 |
+
event.preventDefault(); // Prevent the form from submitting the traditional way
|
| 125 |
+
|
| 126 |
+
var textarea = document.getElementById("textarea");
|
| 127 |
+
var userMessage = "user: " + textarea.value;
|
| 128 |
+
|
| 129 |
+
// Make a request to your server to get the bot's response
|
| 130 |
+
fetch("{{url_for('predict')}}", {
|
| 131 |
+
method: "POST",
|
| 132 |
+
body: new FormData(event.target)
|
| 133 |
+
})
|
| 134 |
+
.then(response => response.text())
|
| 135 |
+
.then(data => {
|
| 136 |
+
var botMessage = "bot: " + data;
|
| 137 |
+
displayMessages(userMessage, botMessage);
|
| 138 |
+
textarea.value = ""; // Clear the textarea
|
| 139 |
+
})
|
| 140 |
+
.catch(error => console.error("Error:", error));
|
| 141 |
+
}
|
| 142 |
+
|
| 143 |
+
function displayMessages(userMessage, botMessage) {
|
| 144 |
+
var messagesDiv = document.getElementById("messages");
|
| 145 |
+
|
| 146 |
+
var userDiv = document.createElement("div");
|
| 147 |
+
userDiv.classList.add("message");
|
| 148 |
+
userDiv.innerHTML = "<div class='user-message'>" + userMessage + "</div>";
|
| 149 |
+
messagesDiv.appendChild(userDiv);
|
| 150 |
+
|
| 151 |
+
var botDiv = document.createElement("div");
|
| 152 |
+
botDiv.classList.add("message");
|
| 153 |
+
botDiv.innerHTML = "<div class='bot-message'>" + botMessage + "</div>";
|
| 154 |
+
messagesDiv.appendChild(botDiv);
|
| 155 |
+
|
| 156 |
+
// Scroll to the bottom of the messages div
|
| 157 |
+
messagesDiv.scrollTop = messagesDiv.scrollHeight;
|
| 158 |
+
}
|
| 159 |
+
</script>
|
| 160 |
</body>
|
| 161 |
</html>
|