RushiMane2003 commited on
Commit
c1efad7
·
verified ·
1 Parent(s): c9cc2fc

made responsive

Browse files
Files changed (1) hide show
  1. templates/index.html +125 -101
templates/index.html CHANGED
@@ -3,155 +3,179 @@
3
  <head>
4
  <meta charset="UTF-8">
5
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
- <title>Smart Irrigation Water Predictor</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: #f0fff0;
 
11
  }
12
- .container {
13
- border: 1px solid #28a745;
14
- padding: 20px;
15
- margin: 40px auto;
16
- background-color: white;
17
- border-radius: 10px;
18
- }
19
- #weather_info {
20
- background-color: #f8f9fa;
21
- border: 2px solid #000;
22
- padding: 15px;
23
- border-radius: 5px;
24
  }
25
- h1 {
26
- color: #28a745;
27
- text-align: center;
28
  font-weight: bold;
29
  }
30
- .input-container {
31
- display: flex;
32
- justify-content: space-between;
33
- height: 100%;
34
  }
35
- .left-input {
36
- width: 53%;
37
- border-right: 2px solid #28a745;
38
- padding-right: 20px;
39
  }
40
- .right-image {
41
- width: 45%;
42
- display: flex;
43
- justify-content: center;
44
- align-items: center;
45
- height: 200%;
46
- margin-top: 50px;
 
47
  }
48
- .right-image img {
49
- width: 100%;
50
- height: 100%;
51
- object-fit: contain;
 
52
  }
53
  .form-control {
54
  border-color: #28a745;
55
- background-color: #f0fff0;
56
  }
57
  .btn-green {
58
  background-color: #28a745;
59
  color: white;
60
  font-weight: bold;
61
  width: 100%;
62
- margin-top: 10px;
 
 
 
 
 
 
 
 
 
 
 
 
63
  }
64
  </style>
65
  </head>
66
  <body>
67
 
 
 
 
 
68
  <div class="container">
69
- <h1>Irrigation Water Requirement Prediction</h1>
70
- <form action="/predict" method="POST">
71
- <div class="input-container">
72
- <div class="left-input">
73
- <div class="form-group">
74
- <label for="crop_type">Crop Type</label>
75
- <select class="form-control" id="crop_type" name="crop_type" required>
76
- <option value="BANANA">Banana</option>
77
- <option value="BEAN">BEAN</option>
78
- <option value="CABBAGE">CABBAGE</option>
79
- <option value="CITRUS">CITRUS</option>
80
- <option value="COTTON">COTTON</option>
81
- <option value="MAIZE">MAIZE</option>
82
- <option value="MELON">MELON</option>
83
- <option value="MUSTARD">MUSTARD</option>
84
- <option value="ONION">ONION</option>
85
- <option value="OTHER">OTHER</option>
86
- <option value="POTATO">POTATO</option>
87
- <option value="RICE">RICE</option>
88
- <option value="SOYABEAN">SOYABEAN</option>
89
- <option value="SUGARCANE">SUGARCANE</option>
90
- <option value="TOMATO">TOMATO</option>
91
- <option value="WHEAT">WHEAT</option>
92
- </select>
93
- </div>
 
 
 
 
 
94
 
95
- <div class="form-group">
96
- <label for="soil_type">Soil Type</label>
97
- <select class="form-control" id="soil_type" name="soil_type" required>
98
- <option value="DRY">Dry</option>
99
- <option value="HUMID">Humid</option>
100
- <option value="WET">Wet</option>
101
- </select>
102
- </div>
103
 
104
- <div class="form-group">
105
- <label for="city">City</label>
106
- <input type="text" class="form-control" id="city" name="city" placeholder="Enter city for weather" required>
107
- </div>
108
- <button type="button" class="btn btn-green" onclick="fetchWeather()">Fetch Weather Data</button>
109
- <div id="weather_info" class="mt-3" style="display: none;">
110
- <p><strong>Weather Info:</strong></p>
111
- <div id="weather_data"></div>
112
- </div>
113
- <div class="form-group mt-3">
114
- <label for="motor_capacity">Motor Capacity (liters/sec)</label>
115
- <input type="text" class="form-control" id="motor_capacity" name="motor_capacity" required>
116
- </div>
117
- <button type="submit" class="btn btn-green">Predict Water Requirement</button>
118
- </div>
 
 
 
 
119
 
120
- <div class="right-image">
121
- <img src="/static/images/img.png" alt="Decorative Image">
122
- </div>
 
 
 
 
123
  </div>
124
- </form>
125
  </div>
126
 
127
  <script>
128
  function fetchWeather() {
129
  const city = document.getElementById('city').value;
130
  if (city) {
 
 
 
 
 
131
  fetch(`/fetch_weather?city=${city}`)
132
  .then(response => response.json())
133
  .then(data => {
134
  if (data) {
135
- document.getElementById('weather_data').innerHTML = `
136
- Weather: ${data.description}<br>
137
- Temperature: ${data.temperature}°C<br>
138
- Humidity: ${data.humidity}%<br>
139
- Pressure: ${data.pressure} hPa
140
  `;
141
- document.getElementById('weather_info').style.display = 'block';
142
  } else {
143
- document.getElementById('weather_data').innerHTML = 'Weather data not available';
144
- document.getElementById('weather_info').style.display = 'block';
145
  }
146
  })
147
  .catch(error => {
148
  console.error('Error fetching weather:', error);
149
- document.getElementById('weather_data').innerHTML = 'Error fetching weather data';
150
- document.getElementById('weather_info').style.display = 'block';
151
  });
 
 
152
  }
153
  }
154
  </script>
155
 
156
  </body>
157
- </html>
 
3
  <head>
4
  <meta charset="UTF-8">
5
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
+ <title>Smart Irrigation Predictor</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: #f4f8f4; /* Lighter green background */
11
+ font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
12
  }
13
+ .navbar {
14
+ background-color: #28a745;
15
+ color: white;
 
 
 
 
 
 
 
 
 
16
  }
17
+ .navbar-brand {
 
 
18
  font-weight: bold;
19
  }
20
+ .container {
21
+ margin-top: 30px;
22
+ margin-bottom: 30px;
 
23
  }
24
+ .card {
25
+ border: none;
26
+ border-radius: 15px;
27
+ box-shadow: 0 4px 12px rgba(0,0,0,0.1);
28
  }
29
+ .card-header {
30
+ background-color: #28a745;
31
+ color: white;
32
+ text-align: center;
33
+ font-weight: bold;
34
+ font-size: 1.5rem;
35
+ border-top-left-radius: 15px;
36
+ border-top-right-radius: 15px;
37
  }
38
+ #weather_info {
39
+ background-color: #e9f5e9;
40
+ border: 1px solid #28a745;
41
+ padding: 15px;
42
+ border-radius: 5px;
43
  }
44
  .form-control {
45
  border-color: #28a745;
46
+ background-color: #fafffa;
47
  }
48
  .btn-green {
49
  background-color: #28a745;
50
  color: white;
51
  font-weight: bold;
52
  width: 100%;
53
+ padding: 10px;
54
+ border-radius: 5px;
55
+ transition: background-color 0.3s;
56
+ }
57
+ .btn-green:hover {
58
+ background-color: #218838;
59
+ }
60
+ .hero-image {
61
+ width: 100%;
62
+ height: auto;
63
+ max-height: 400px;
64
+ object-fit: cover;
65
+ border-radius: 10px;
66
  }
67
  </style>
68
  </head>
69
  <body>
70
 
71
+ <nav class="navbar navbar-dark">
72
+ <span class="navbar-brand mb-0 h1 mx-auto">🌱 Smart Irrigation Water Predictor</span>
73
+ </nav>
74
+
75
  <div class="container">
76
+ <div class="card">
77
+ <div class="card-header">
78
+ Predict Irrigation Water Requirement
79
+ </div>
80
+ <div class="card-body">
81
+ <form action="/predict" method="POST">
82
+ <div class="row align-items-center">
83
+ <!-- Left side: Form Inputs -->
84
+ <div class="col-lg-6">
85
+ <div class="form-group">
86
+ <label for="crop_type"><strong>Crop Type</strong></label>
87
+ <select class="form-control" id="crop_type" name="crop_type" required>
88
+ <option value="BANANA">Banana</option>
89
+ <option value="BEAN">Bean</option>
90
+ <option value="CABBAGE">Cabbage</option>
91
+ <option value="CITRUS">Citrus</option>
92
+ <option value="COTTON">Cotton</option>
93
+ <option value="MAIZE">Maize</option>
94
+ <option value="MELON">Melon</option>
95
+ <option value="MUSTARD">Mustard</option>
96
+ <option value="ONION">Onion</option>
97
+ <option value="OTHER">Other</option>
98
+ <option value="POTATO">Potato</option>
99
+ <option value="RICE">Rice</option>
100
+ <option value="SOYABEAN">Soyabean</option>
101
+ <option value="SUGARCANE">Sugarcane</option>
102
+ <option value="TOMATO">Tomato</option>
103
+ <option value="WHEAT">Wheat</option>
104
+ </select>
105
+ </div>
106
 
107
+ <div class="form-group">
108
+ <label for="soil_type"><strong>Soil Type</strong></label>
109
+ <select class="form-control" id="soil_type" name="soil_type" required>
110
+ <option value="DRY">Dry</option>
111
+ <option value="HUMID">Humid</option>
112
+ <option value="WET">Wet</option>
113
+ </select>
114
+ </div>
115
 
116
+ <div class="form-group">
117
+ <label for="city"><strong>City / Location</strong></label>
118
+ <input type="text" class="form-control" id="city" name="city" placeholder="Enter city for weather data" required>
119
+ </div>
120
+
121
+ <button type="button" class="btn btn-secondary btn-block" onclick="fetchWeather()">Fetch Weather Data</button>
122
+
123
+ <div id="weather_info" class="mt-3" style="display: none;">
124
+ <p><strong>Weather Information:</strong></p>
125
+ <div id="weather_data"></div>
126
+ </div>
127
+
128
+ <div class="form-group mt-3">
129
+ <label for="motor_capacity"><strong>Motor Capacity (liters/sec)</strong></label>
130
+ <input type="text" class="form-control" id="motor_capacity" name="motor_capacity" required>
131
+ </div>
132
+
133
+ <button type="submit" class="btn btn-green mt-3">Predict Water Requirement</button>
134
+ </div>
135
 
136
+ <!-- Right side: Image -->
137
+ <div class="col-lg-6 d-none d-lg-block text-center">
138
+ <img src="../static/images/img.png"
139
+ alt="Smart Irrigation" class="hero-image">
140
+ </div>
141
+ </div>
142
+ </form>
143
  </div>
144
+ </div>
145
  </div>
146
 
147
  <script>
148
  function fetchWeather() {
149
  const city = document.getElementById('city').value;
150
  if (city) {
151
+ const weatherDiv = document.getElementById('weather_data');
152
+ const weatherInfoBox = document.getElementById('weather_info');
153
+ weatherDiv.innerHTML = 'Fetching weather...';
154
+ weatherInfoBox.style.display = 'block';
155
+
156
  fetch(`/fetch_weather?city=${city}`)
157
  .then(response => response.json())
158
  .then(data => {
159
  if (data) {
160
+ weatherDiv.innerHTML = `
161
+ <strong>Weather:</strong> ${data.description}<br>
162
+ <strong>Temperature:</strong> ${data.temperature}°C<br>
163
+ <strong>Humidity:</strong> ${data.humidity}%<br>
164
+ <strong>Pressure:</strong> ${data.pressure} hPa
165
  `;
 
166
  } else {
167
+ weatherDiv.innerHTML = 'Could not retrieve weather data for the specified city.';
 
168
  }
169
  })
170
  .catch(error => {
171
  console.error('Error fetching weather:', error);
172
+ weatherDiv.innerHTML = 'An error occurred while fetching weather data.';
 
173
  });
174
+ } else {
175
+ alert('Please enter a city name first.');
176
  }
177
  }
178
  </script>
179
 
180
  </body>
181
+ </html>