Update templates/index.html
Browse files- templates/index.html +242 -153
templates/index.html
CHANGED
|
@@ -1,153 +1,242 @@
|
|
| 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>Crop Recommendation System</title>
|
| 7 |
-
<link href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css" rel="stylesheet">
|
| 8 |
-
<style>
|
| 9 |
-
body {
|
| 10 |
-
background-color: #eef7ee;
|
| 11 |
-
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
|
| 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 |
-
.form-
|
| 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 |
-
text-align:
|
| 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 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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>Crop Recommendation System</title>
|
| 7 |
+
<link href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css" rel="stylesheet">
|
| 8 |
+
<style>
|
| 9 |
+
body {
|
| 10 |
+
background-color: #eef7ee;
|
| 11 |
+
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
|
| 12 |
+
margin: 0; /* Remove default body margin */
|
| 13 |
+
padding: 0; /* Remove default body padding */
|
| 14 |
+
}
|
| 15 |
+
.container {
|
| 16 |
+
margin: 30px auto; /* Adjust margin for better spacing on all screens */
|
| 17 |
+
padding: 20px; /* Adjust padding */
|
| 18 |
+
border: 2px solid #28a745;
|
| 19 |
+
border-radius: 15px;
|
| 20 |
+
max-width: 1200px;
|
| 21 |
+
background-color: #f9fff9;
|
| 22 |
+
box-shadow: 0px 0px 15px rgba(0, 0, 0, 0.2);
|
| 23 |
+
}
|
| 24 |
+
h1 {
|
| 25 |
+
color: #28a745;
|
| 26 |
+
font-weight: bold;
|
| 27 |
+
text-align: center;
|
| 28 |
+
margin-bottom: 30px;
|
| 29 |
+
font-size: 2.5rem; /* Responsive font size for H1 */
|
| 30 |
+
}
|
| 31 |
+
.input-section {
|
| 32 |
+
display: flex;
|
| 33 |
+
justify-content: space-between;
|
| 34 |
+
align-items: flex-start;
|
| 35 |
+
flex-wrap: wrap; /* Allow items to wrap on smaller screens */
|
| 36 |
+
}
|
| 37 |
+
.form-group {
|
| 38 |
+
width: 60%;
|
| 39 |
+
padding-right: 15px; /* Add some padding for spacing */
|
| 40 |
+
}
|
| 41 |
+
.form-label {
|
| 42 |
+
display: block;
|
| 43 |
+
margin-top: 15px;
|
| 44 |
+
font-weight: bold;
|
| 45 |
+
}
|
| 46 |
+
.form-control {
|
| 47 |
+
width: 100%;
|
| 48 |
+
}
|
| 49 |
+
.image-section {
|
| 50 |
+
width: 35%;
|
| 51 |
+
display: flex;
|
| 52 |
+
justify-content: center;
|
| 53 |
+
align-items: center;
|
| 54 |
+
margin-top: 50px;
|
| 55 |
+
margin-left: -30px;
|
| 56 |
+
padding-left: 15px; /* Add some padding for spacing */
|
| 57 |
+
}
|
| 58 |
+
.image-section img {
|
| 59 |
+
max-width: 100%;
|
| 60 |
+
height: 580px; /* Keep height for larger screens */
|
| 61 |
+
border-radius: 10px;
|
| 62 |
+
border: 3px solid #28a745;
|
| 63 |
+
object-fit: cover; /* Ensures the image covers the area without distortion */
|
| 64 |
+
}
|
| 65 |
+
.btn-predict {
|
| 66 |
+
background-color: #28a745;
|
| 67 |
+
color: white;
|
| 68 |
+
font-weight: bold;
|
| 69 |
+
margin-top: 30px; /* Increase top margin for button */
|
| 70 |
+
width: 100%;
|
| 71 |
+
padding: 12px; /* Make button more clickable */
|
| 72 |
+
font-size: 1.1rem; /* Adjust button font size */
|
| 73 |
+
}
|
| 74 |
+
.result-container {
|
| 75 |
+
margin-top: 30px;
|
| 76 |
+
border: 2px solid #28a745;
|
| 77 |
+
padding: 20px;
|
| 78 |
+
background-color: #e3ffe3;
|
| 79 |
+
border-radius: 10px;
|
| 80 |
+
box-shadow: 0px 0px 10px rgba(0, 0, 0, 0.1);
|
| 81 |
+
}
|
| 82 |
+
.result-container h3 {
|
| 83 |
+
color: #28a745;
|
| 84 |
+
text-align: center;
|
| 85 |
+
margin-bottom: 20px;
|
| 86 |
+
font-size: 1.8rem; /* Responsive font size for H3 */
|
| 87 |
+
}
|
| 88 |
+
.ai-suggestions {
|
| 89 |
+
margin-top: 20px;
|
| 90 |
+
background-color: #ffffff;
|
| 91 |
+
padding: 15px;
|
| 92 |
+
border-radius: 10px;
|
| 93 |
+
border: 1px solid #28a745;
|
| 94 |
+
box-shadow: 0px 0px 5px rgba(0, 0, 0, 0.1);
|
| 95 |
+
text-align: left;
|
| 96 |
+
line-height: 1.6; /* Improve readability */
|
| 97 |
+
}
|
| 98 |
+
|
| 99 |
+
/* --- Media Queries for Responsiveness --- */
|
| 100 |
+
|
| 101 |
+
/* Tablets and smaller desktops (e.g., Bootstrap's md breakpoint) */
|
| 102 |
+
@media (max-width: 991.98px) {
|
| 103 |
+
.container {
|
| 104 |
+
margin: 20px auto;
|
| 105 |
+
padding: 15px;
|
| 106 |
+
}
|
| 107 |
+
h1 {
|
| 108 |
+
font-size: 2rem;
|
| 109 |
+
}
|
| 110 |
+
.form-group {
|
| 111 |
+
width: 100%; /* Full width for form inputs */
|
| 112 |
+
padding-right: 0;
|
| 113 |
+
}
|
| 114 |
+
.image-section {
|
| 115 |
+
width: 100%; /* Full width for image */
|
| 116 |
+
margin-top: 30px; /* Adjust top margin */
|
| 117 |
+
margin-left: 0; /* Reset left margin */
|
| 118 |
+
padding-left: 0;
|
| 119 |
+
order: -1; /* Place image above form fields on smaller screens */
|
| 120 |
+
}
|
| 121 |
+
.image-section img {
|
| 122 |
+
max-height: 400px; /* Limit image height on smaller screens */
|
| 123 |
+
height: auto; /* Allow height to adjust proportionally */
|
| 124 |
+
}
|
| 125 |
+
}
|
| 126 |
+
|
| 127 |
+
/* Mobile devices (e.g., Bootstrap's sm breakpoint) */
|
| 128 |
+
@media (max-width: 767.98px) {
|
| 129 |
+
h1 {
|
| 130 |
+
font-size: 1.8rem;
|
| 131 |
+
margin-bottom: 20px;
|
| 132 |
+
}
|
| 133 |
+
.form-label {
|
| 134 |
+
margin-top: 10px;
|
| 135 |
+
}
|
| 136 |
+
.btn-predict {
|
| 137 |
+
margin-top: 20px;
|
| 138 |
+
padding: 10px;
|
| 139 |
+
font-size: 1rem;
|
| 140 |
+
}
|
| 141 |
+
.result-container {
|
| 142 |
+
padding: 15px;
|
| 143 |
+
}
|
| 144 |
+
.result-container h3 {
|
| 145 |
+
font-size: 1.5rem;
|
| 146 |
+
}
|
| 147 |
+
.ai-suggestions {
|
| 148 |
+
padding: 10px;
|
| 149 |
+
font-size: 0.95rem;
|
| 150 |
+
}
|
| 151 |
+
.image-section {
|
| 152 |
+
margin-top: 20px;
|
| 153 |
+
}
|
| 154 |
+
.image-section img {
|
| 155 |
+
max-height: 250px; /* Further limit image height on very small screens */
|
| 156 |
+
}
|
| 157 |
+
}
|
| 158 |
+
|
| 159 |
+
/* Extra small devices */
|
| 160 |
+
@media (max-width: 575.98px) {
|
| 161 |
+
h1 {
|
| 162 |
+
font-size: 1.5rem;
|
| 163 |
+
}
|
| 164 |
+
.container {
|
| 165 |
+
margin: 15px;
|
| 166 |
+
padding: 10px;
|
| 167 |
+
}
|
| 168 |
+
}
|
| 169 |
+
</style>
|
| 170 |
+
</head>
|
| 171 |
+
<body>
|
| 172 |
+
<div class="container">
|
| 173 |
+
<h1>Crop Recommendation System</h1>
|
| 174 |
+
<form id="cropForm" method="POST">
|
| 175 |
+
<div class="input-section">
|
| 176 |
+
<div class="form-group">
|
| 177 |
+
<label class="form-label" for="location">Enter Location</label>
|
| 178 |
+
<input type="text" class="form-control" id="location" name="location" required>
|
| 179 |
+
|
| 180 |
+
<label class="form-label" for="nitrogen">Enter Nitrogen (N)</label>
|
| 181 |
+
<input type="text" class="form-control" id="nitrogen" name="nitrogen" required>
|
| 182 |
+
|
| 183 |
+
<label class="form-label" for="phosphorus">Enter Phosphorus (p)</label>
|
| 184 |
+
<input type="text" class="form-control" id="phosphorus" name="phosphorus" required>
|
| 185 |
+
|
| 186 |
+
<label class="form-label" for="potassium">Enter Potassium (k)</label>
|
| 187 |
+
<input type="text" class="form-control" id="potassium" name="potassium" required>
|
| 188 |
+
|
| 189 |
+
<label class="form-label" for="temperature">Enter Temperature (°C)</label>
|
| 190 |
+
<input type="text" class="form-control" id="temperature" name="temperature" required>
|
| 191 |
+
|
| 192 |
+
<label class="form-label" for="humidity">Enter Humidity (%)</label>
|
| 193 |
+
<input type="text" class="form-control" id="humidity" name="humidity" required>
|
| 194 |
+
|
| 195 |
+
<label class="form-label" for="ph">Enter pH Level</label>
|
| 196 |
+
<input type="text" class="form-control" id="ph" name="ph" required>
|
| 197 |
+
|
| 198 |
+
<label class="form-label" for="rainfall">Enter Rainfall (mm)</label>
|
| 199 |
+
<input type="text" class="form-control" id="rainfall" name="rainfall" required>
|
| 200 |
+
</div>
|
| 201 |
+
<div class="image-section">
|
| 202 |
+
<img src="https://www.shutterstock.com/image-photo/young-corn-plants-growing-on-600nw-2299683499.jpg" alt="Crop Image">
|
| 203 |
+
</div>
|
| 204 |
+
</div>
|
| 205 |
+
<button type="submit" class="btn btn-predict">Predict Crop</button>
|
| 206 |
+
</form>
|
| 207 |
+
|
| 208 |
+
<!-- Results will be shown here -->
|
| 209 |
+
<div class="result-container" id="resultContainer" style="display:none;">
|
| 210 |
+
<h3>Predicted Crop: <span id="predictedCrop"></span></h3>
|
| 211 |
+
<div class="ai-suggestions" id="aiSuggestions"></div>
|
| 212 |
+
</div>
|
| 213 |
+
</div>
|
| 214 |
+
|
| 215 |
+
<!-- Bootstrap and jQuery JS -->
|
| 216 |
+
<script src="https://code.jquery.com/jquery-3.5.1.min.js"></script>
|
| 217 |
+
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/js/bootstrap.bundle.min.js"></script>
|
| 218 |
+
<script>
|
| 219 |
+
$(document).ready(function() {
|
| 220 |
+
$('#cropForm').on('submit', function(event) {
|
| 221 |
+
event.preventDefault();
|
| 222 |
+
$.ajax({
|
| 223 |
+
url: '/predict', // Ensure this URL matches your backend endpoint
|
| 224 |
+
type: 'POST',
|
| 225 |
+
data: $(this).serialize(),
|
| 226 |
+
success: function(response) {
|
| 227 |
+
$('#predictedCrop').text(response.predicted_crop);
|
| 228 |
+
$('#aiSuggestions').text(response.ai_suggestions);
|
| 229 |
+
$('#resultContainer').show();
|
| 230 |
+
},
|
| 231 |
+
error: function(xhr, status, error) {
|
| 232 |
+
console.error("AJAX Error:", status, error);
|
| 233 |
+
$('#predictedCrop').text("Error predicting crop.");
|
| 234 |
+
$('#aiSuggestions').text("Please try again or check your input values.");
|
| 235 |
+
$('#resultContainer').show();
|
| 236 |
+
}
|
| 237 |
+
});
|
| 238 |
+
});
|
| 239 |
+
});
|
| 240 |
+
</script>
|
| 241 |
+
</body>
|
| 242 |
+
</html>
|