Spaces:
Running
Running
File size: 12,248 Bytes
14b6dbb |
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 54 55 56 57 58 59 60 61 62 63 64 65 66 67 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 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 |
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link href='https://fonts.googleapis.com/css?family=Poppins' rel='stylesheet'>
<link rel="stylesheet" href="{{ url_for('static', filename='styles.css') }}">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0-beta3/css/all.min.css">
<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
<title>Farm Tech System</title>
<style>
body {
font-family: Arial, sans-serif;
}
.container {
display: flex;
justify-content: space-between;
margin-top: 20px;
text-align: center;
}
.column {
flex: 0 0 48%;
padding: 30px;
border: 1px solid #ccc;
box-shadow: 2px 2px 12px #aaa;
background-color: rgba(240, 240, 240, 0.7);
}
.attention {
background-color: #ffcccc;
padding: 10px;
border: 1px solid #ff6666;
margin-bottom: -200px;
text-align: center;
width: 48%;
box-sizing: border-box;
animation: blink 1s infinite;
}
@keyframes blink {
0% { background-color: #ffcccc; }
50% { background-color: #ff9999; }
100% { background-color: #ffcccc; }
}
@keyframes pulsate {
0% { opacity: 1; }
50% { opacity: 0.5; }
100% { opacity: 1; }
}
.attention p {
font-weight: bold;
color: #cc0000;
margin: 0;
}
.attention span {
color: blue;
}
.attention-left {
margin-right: 10px;
}
.attention-right {
margin-left: auto;
}
.live {
animation: pulsate 1s infinite;
color: red;
font-weight: bold;
}
.chatbot-icon, .voice-icon {
position: fixed;
bottom: 30px;
background-color: #AC3B61;
color: #fff;
border-radius: 50%;
width: 70px;
height: 70px;
display: flex;
align-items: center;
justify-content: center;
cursor: pointer;
transition: transform 0.3s;
font-size: 24px;
box-shadow: 0 4px 8px rgba(0,0,0,0.2);
}
.chatbot-icon {
right: 30px;
}
.voice-icon {
right: 110px;
}
.voice-active {
animation: pulse 1s infinite;
}
@keyframes pulse {
0% { transform: scale(1); }
50% { transform: scale(1.1); }
100% { transform: scale(1); }
}
.chatbox {
position: fixed;
bottom: 120px;
right: 30px;
width: 400px;
max-width: 90%;
height: 600px;
max-height: 80vh;
background: #fff;
box-shadow: 0 5px 15px rgba(0,0,0,0.2);
border-radius: 20px;
display: none;
flex-direction: column;
overflow: hidden;
}
.chatbox-header {
padding: 15px;
font-size: 20px;
background: linear-gradient(45deg, #AC3B61, #8E2D4E);
color: white;
border-top-left-radius: 20px;
border-top-right-radius: 20px;
}
.chatbox-body {
height: calc(100% - 130px);
padding: 20px;
overflow-y: auto;
background-color: #f7f7f7;
}
.chatbox-footer {
padding: 15px;
background-color: white;
border-bottom-left-radius: 20px;
border-bottom-right-radius: 20px;
display: flex;
align-items: center;
}
.chatbox-footer input {
flex: 1;
padding: 12px;
border: 1px solid #ddd;
border-radius: 25px;
font-size: 16px;
margin-right: 10px;
}
.chatbox-footer button {
padding: 12px 20px;
background: linear-gradient(45deg, #AC3B61, #8E2D4E);
color: white;
border: none;
border-radius: 25px;
font-size: 16px;
cursor: pointer;
transition: background 0.3s ease;
}
.chatbox-footer button:hover {
background: linear-gradient(45deg, #8E2D4E, #AC3B61);
}
.message {
margin-bottom: 12px;
padding: 8px 12px;
border-radius: 16px;
max-width: 80%;
word-wrap: break-word;
animation: fadeIn 0.3s ease;
font-size: 14px; /* Reduced font size for chat messages */
}
.user-message {
background-color: #E1F5FE;
color: #0277BD;
margin-left: auto;
}
.bot-message {
background-color: #FFF3E0;
color: #E65100;
}
@keyframes fadeIn {
from { opacity: 0; transform: translateY(10px); }
to { opacity: 1; transform: translateY(0); }
}
.typing-indicator {
display: inline-block;
}
.typing-indicator span {
display: inline-block;
animation: blink 1.4s infinite both;
}
.typing-indicator span:nth-child(2) {
animation-delay: .2s;
}
.typing-indicator span:nth-child(3) {
animation-delay: .4s;
}
</style>
</head>
<body>
<div class="body">
<div class="container">
<div class="row">
<div class="col-md-12 text-center">
<h1 class="animate-charcter">Farm Tech System-Home</h1>
</div>
</div>
</div>
<header>
<nav class="navbar">
<ul class="nav-links">
<li><a href="sensors"><i class="fas fa-home"></i> Sensors</a></li>
<li><a href="zones"><i class="fas fa-cogs"></i> Zones</a></li>
<li><a href="activity-log"><i class="fas fa-envelope"></i> Activity Log</a></li>
<li><a href="notification"><i class="fas fa-bell"></i> Notifications</a></li>
</ul>
</nav>
</header>
<main>
<h1 style="text-align: center; color: white;">Test your crop health!!!</h1>
<p style="font-size: 20px; text-align: center; color: white;">
Temperature: 32°C, Humidity: 95%, Moisture: High (<span class="live">live</span>)
</p>
<div class="container">
<div class="attention attention-left">
<p>
Attention: This weather condition may lead to outbreak of <span>Tea mosquito bug</span> (Action Needed)
</p>
</div>
<div class="attention attention-right">
<p>
Attention: This weather condition may lead to outbreak of <span>Blister blight disease</span> (Action Needed)
</p>
</div>
</div>
<div class="container">
<div class="column">
<h2>Tea Crop Pest Detection</h2>
<form method="post" enctype="multipart/form-data">
<input type="file" name="pest_file" accept="image/*" required>
<br><br>
<input type="submit" value="Upload">
</form>
{% if pest_filename %}
<h3>Uploaded Photo:</h3>
<img src="{{ url_for('uploaded_file', filename=pest_filename) }}" alt="Uploaded Photo" style="max-width: 100%; height: auto;">
<h3>Detected Pest: <span>Tea mosquito bug</span></h3>
<p>Remedy:</p>
<ul>
<li>Spray neem oil on the affected areas.</li>
<li>Use yellow sticky traps to catch the bugs.</li>
<li>Plant trap crops like castor or sunflower to divert them away from tea plants.</li>
</ul>
<audio id="pest_audio" src="{{ url_for('audio_file', filename=pest_audio_file) }}" controls autoplay></audio>
{% endif %}
</div>
<div class="column">
<h2>Tea Crop Disease Detection</h2>
<form method="post" enctype="multipart/form-data">
<input type="file" name="disease_file" accept="image/*" required>
<br><br>
<input type="submit" value="Upload">
</form>
{% if disease_filename %}
<h3>Uploaded Photo:</h3>
<img src="{{ url_for('uploaded_file', filename=disease_filename) }}" alt="Uploaded Photo" style="max-width: 100%; height: auto;">
<h3>Detected Disease: <span>Brown Blight disease</span></h3>
<p>Remedy:</p>
<ul>
<li>Remove and destroy infected leaves.</li>
<li>Apply copper-based fungicides.</li>
<li>Ensure proper air circulation around the plants.</li>
</ul>
<audio id="disease_audio" src="{{ url_for('audio_file', filename=disease_audio_file) }}" controls autoplay></audio>
{% endif %}
</div>
</div>
</main>
</div>
<!-- Chatbot Icon -->
<div class="chatbot-icon" id="chatbotIcon">
<i class="fas fa-comments"></i>
</div>
<!-- Voice Icon -->
<div class="voice-icon" id="voiceIcon">
<i class="fas fa-microphone"></i>
</div>
<!-- Chatbox -->
<div class="chatbox" id="chatbox">
<div class="chatbox-header">Chat with AI</div>
<div class="chatbox-body" id="chatBody">
<!-- Chat content goes here -->
</div>
<div class="chatbox-footer">
<input type="text" placeholder="Type your message here..." id="chatInput">
<button id="sendButton">Send</button>
</div>
</div>
<script>
// JavaScript to handle the chatbot toggle
document.getElementById('chatbotIcon').addEventListener('click', function() {
var chatbox = document.getElementById('chatbox');
if (chatbox.style.display === 'none' || chatbox.style.display === '') {
chatbox.style.display = 'flex';
} else {
chatbox.style.display = 'none';
}
});
// JavaScript for voice recognition
var recognition;
if ('webkitSpeechRecognition' in window) {
recognition = new webkitSpeechRecognition();
} else if ('SpeechRecognition' in window) {
recognition = new SpeechRecognition();
} else {
alert('Your browser does not support speech recognition.');
}
if (recognition) {
recognition.continuous = false;
recognition.interimResults = false;
recognition.onstart = function() {
document.getElementById('voiceIcon').classList.add('voice-active');
};
recognition.onend = function() {
document.getElementById('voiceIcon').classList.remove('voice-active');
};
recognition.onresult = function(event) {
var transcript = event.results[0][0].transcript;
document.getElementById('chatInput').value = transcript;
};
document.getElementById('voiceIcon').addEventListener('click', function() {
recognition.start();
});
}
// Chat functionality
$(document).ready(function() {
$('#sendButton').click(sendMessage);
$('#chatInput').keypress(function(e) {
if (e.which == 13) {
sendMessage();
}
});
function sendMessage() {
var message = $('#chatInput').val();
if (message.trim() !== '') {
appendMessage('user', message);
$('#chatInput').val('');
// Show a typing indicator
appendMessage('bot', '<div class="typing-indicator">Typing<span>.</span><span>.</span><span>.</span></div>');
$.ajax({
url: '/chat',
method: 'POST',
contentType: 'application/json',
data: JSON.stringify({message: message}),
success: function(response) {
// Remove the typing indicator
$('.typing-indicator').parent().remove();
appendMessage('bot', response.response);
},
error: function() {
// Remove the typing indicator
$('.typing-indicator').parent().remove();
appendMessage('bot', 'Sorry, there was an error processing your request.');
}
});
}
}
function appendMessage(sender, message) {
var messageClass = sender === 'user' ? 'user-message' : 'bot-message';
$('#chatBody').append('<div class="message ' + messageClass + '">' + message + '</div>');
$('#chatBody').scrollTop($('#chatBody')[0].scrollHeight);
}
});
</script>
</body>
</html> |