pranit144 commited on
Commit
a650dd6
·
verified ·
1 Parent(s): 550ee19

Update templates/index.html

Browse files
Files changed (1) hide show
  1. 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
- .container {
14
- margin: 50px auto;
15
- padding: 30px;
16
- border: 2px solid #28a745;
17
- border-radius: 15px;
18
- max-width: 1200px;
19
- background-color: #f9fff9;
20
- box-shadow: 0px 0px 15px rgba(0, 0, 0, 0.2);
21
- }
22
- h1 {
23
- color: #28a745;
24
- font-weight: bold;
25
- text-align: center;
26
- margin-bottom: 30px;
27
- }
28
- .input-section {
29
- display: flex;
30
- justify-content: space-between;
31
- align-items: flex-start;
32
- }
33
- .form-group {
34
- width: 60%;
35
- }
36
- .form-label {
37
- display: block;
38
- margin-top: 15px;
39
- font-weight: bold;
40
- }
41
- .form-control {
42
- width: 100%;
43
- }
44
- .image-section {
45
- width: 35%;
46
- display: flex;
47
- justify-content: center;
48
- align-items: center;
49
- margin-top: 50px; /* Moves the image section down */
50
- margin-left: -30px; /* Aligns the image section a little to the left */
51
- }
52
- .image-section img {
53
- max-width: 100%;
54
- height: 580px;
55
- border-radius: 10px;
56
- border: 3px solid #28a745; /* Green border around the image */
57
- }
58
- .btn-predict {
59
- background-color: #28a745;
60
- color: white;
61
- font-weight: bold;
62
- margin-top: 20px;
63
- width: 100%;
64
- }
65
- .result-container {
66
- margin-top: 30px;
67
- border: 2px solid #28a745;
68
- padding: 20px;
69
- background-color: #e3ffe3;
70
- border-radius: 10px;
71
- box-shadow: 0px 0px 10px rgba(0, 0, 0, 0.1);
72
- }
73
- .result-container h3 {
74
- color: #28a745;
75
- text-align: center;
76
- }
77
- .ai-suggestions {
78
- margin-top: 20px;
79
- background-color: #ffffff;
80
- padding: 15px;
81
- border-radius: 10px;
82
- border: 1px solid #28a745;
83
- box-shadow: 0px 0px 5px rgba(0, 0, 0, 0.1);
84
- text-align: left;
85
- }
86
- </style>
87
- </head>
88
- <body>
89
- <div class="container">
90
- <h1>Crop Recommendation System</h1>
91
- <form id="cropForm" method="POST">
92
- <div class="input-section">
93
- <div class="form-group">
94
- <label class="form-label" for="location">Enter Location</label>
95
- <input type="text" class="form-control" id="location" name="location" required>
96
-
97
- <label class="form-label" for="nitrogen">Enter Nitrogen (N)</label>
98
- <input type="text" class="form-control" id="nitrogen" name="nitrogen" required>
99
-
100
- <label class="form-label" for="phosphorus">Enter Phosphorus (p)</label>
101
- <input type="text" class="form-control" id="phosphorus" name="phosphorus" required>
102
-
103
- <label class="form-label" for="potassium">Enter Potassium (k)</label>
104
- <input type="text" class="form-control" id="potassium" name="potassium" required>
105
-
106
- <label class="form-label" for="temperature">Enter Temperature (°C)</label>
107
- <input type="text" class="form-control" id="temperature" name="temperature" required>
108
-
109
- <label class="form-label" for="humidity">Enter Humidity (%)</label>
110
- <input type="text" class="form-control" id="humidity" name="humidity" required>
111
-
112
- <label class="form-label" for="ph">Enter pH Level</label>
113
- <input type="text" class="form-control" id="ph" name="ph" required>
114
-
115
- <label class="form-label" for="rainfall">Enter Rainfall (mm)</label>
116
- <input type="text" class="form-control" id="rainfall" name="rainfall" required>
117
- </div>
118
- <div class="image-section">
119
- <img src="https://www.shutterstock.com/image-photo/young-corn-plants-growing-on-600nw-2299683499.jpg" alt="Crop Image">
120
- </div>
121
- </div>
122
- <button type="submit" class="btn btn-predict">Predict Crop</button>
123
- </form>
124
-
125
- <!-- Results will be shown here -->
126
- <div class="result-container" id="resultContainer" style="display:none;">
127
- <h3>Predicted Crop: <span id="predictedCrop"></span></h3>
128
- <div class="ai-suggestions" id="aiSuggestions"></div>
129
- </div>
130
- </div>
131
-
132
- <!-- Bootstrap and jQuery JS -->
133
- <script src="https://code.jquery.com/jquery-3.5.1.min.js"></script>
134
- <script src="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/js/bootstrap.bundle.min.js"></script>
135
- <script>
136
- $(document).ready(function() {
137
- $('#cropForm').on('submit', function(event) {
138
- event.preventDefault();
139
- $.ajax({
140
- url: '/predict',
141
- type: 'POST',
142
- data: $(this).serialize(),
143
- success: function(response) {
144
- $('#predictedCrop').text(response.predicted_crop);
145
- $('#aiSuggestions').text(response.ai_suggestions);
146
- $('#resultContainer').show();
147
- }
148
- });
149
- });
150
- });
151
- </script>
152
- </body>
153
- </html>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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>