File size: 5,526 Bytes
2014c64
 
 
3513d37
 
cf1171e
3513d37
 
 
cf1171e
 
3513d37
ebacf5a
cf1171e
 
 
 
 
3513d37
cf1171e
 
 
 
 
3513d37
cf1171e
 
ebacf5a
 
3513d37
cf1171e
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3513d37
 
 
cf1171e
3513d37
 
 
 
 
 
cf1171e
 
 
 
 
 
 
 
 
 
 
 
 
3513d37
 
2014c64
 
 
cf1171e
 
 
ebacf5a
2014c64
cf1171e
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
ebacf5a
cf1171e
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3513d37
cf1171e
2014c64
 
 
 
 
 
cf1171e
 
 
 
ebacf5a
2014c64
 
 
 
cf1171e
 
 
 
 
2014c64
cf1171e
2014c64
cf1171e
 
2014c64
 
 
 
cf1171e
 
2014c64
cf1171e
 
2014c64
 
 
 
 
ebacf5a
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
<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Smart Irrigation Water Predictor</title>
  <link href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css" rel="stylesheet">
  <style>
      body {
          background-color: #f0fff0;

      }
      .container {
          border: 1px solid #28a745;
          padding: 20px;
          margin: 40px auto;
          background-color: white;
          border-radius: 10px;
      }
      #weather_info {
          background-color: #f8f9fa;
          border: 2px solid #000;
          padding: 15px;
          border-radius: 5px;
      }
      h1 {
          color: #28a745;
          text-align: center;
          font-weight: bold;
      }
      .input-container {
          display: flex;
          justify-content: space-between;
          height: 100%;
      }
      .left-input {
          width: 53%;
          border-right: 2px solid #28a745;
          padding-right: 20px;
      }
      .right-image {
          width: 45%;
          display: flex;
          justify-content: center;
          align-items: center;
          height: 200%;
          margin-top: 50px;

      }
      .right-image img {
          width: 100%;
          height: 100%;
          object-fit: contain;

      }
      .form-control {
          border-color: #28a745;
          background-color: #f0fff0;
      }
      .btn-green {
          background-color: #28a745;
          color: white;
          font-weight: bold;
          width: 100%;
          margin-top: 10px;












      }
  </style>
</head>
<body>





<div class="container">
  <h1>Irrigation Water Requirement Prediction</h1>
  <form action="/predict" method="POST">
    <div class="input-container">
      <div class="left-input">
        <div class="form-group">
          <label for="crop_type">Crop Type</label>
          <select class="form-control" id="crop_type" name="crop_type" required>
            <option value="BANANA">Banana</option>
            <option value="BEAN">BEAN</option>
            <option value="CABBAGE">CABBAGE</option>
            <option value="CITRUS">CITRUS</option>
            <option value="COTTON">COTTON</option>
            <option value="MAIZE">MAIZE</option>
            <option value="MELON">MELON</option>
            <option value="MUSTARD">MUSTARD</option>
            <option value="ONION">ONION</option>
            <option value="OTHER">OTHER</option>
            <option value="POTATO">POTATO</option>
            <option value="RICE">RICE</option>
            <option value="SOYABEAN">SOYABEAN</option>
            <option value="SUGARCANE">SUGARCANE</option>
            <option value="TOMATO">TOMATO</option>
            <option value="WHEAT">WHEAT</option>
          </select>
        </div>






        <div class="form-group">
          <label for="soil_type">Soil Type</label>
          <select class="form-control" id="soil_type" name="soil_type" required>
            <option value="DRY">Dry</option>
            <option value="HUMID">Humid</option>
            <option value="WET">Wet</option>
          </select>
        </div>

        <div class="form-group">
          <label for="city">City</label>
          <input type="text" class="form-control" id="city" name="city" placeholder="Enter city for weather" required>
        </div>
        <button type="button" class="btn btn-green" onclick="fetchWeather()">Fetch Weather Data</button>
        <div id="weather_info" class="mt-3" style="display: none;">
           <p><strong>Weather Info:</strong></p>
           <div id="weather_data"></div>
        </div>
        <div class="form-group mt-3">
          <label for="motor_capacity">Motor Capacity (liters/sec)</label>
          <input type="text" class="form-control" id="motor_capacity" name="motor_capacity" required>
        </div>
        <button type="submit" class="btn btn-green">Predict Water Requirement</button>
      </div>





      <div class="right-image">
        <img src="/static/images/img.png" alt="Decorative Image">
      </div>




    </div>
  </form>
</div>

<script>
    function fetchWeather() {
        const city = document.getElementById('city').value;
        if (city) {





            fetch(`/fetch_weather?city=${city}`)
                .then(response => response.json())
                .then(data => {
                    if (data) {
                        document.getElementById('weather_data').innerHTML = `
                            Weather: ${data.description}<br>
                            Temperature: ${data.temperature}°C<br>
                            Humidity: ${data.humidity}%<br>
                            Pressure: ${data.pressure} hPa
                        `;
                        document.getElementById('weather_info').style.display = 'block';
                    } else {
                        document.getElementById('weather_data').innerHTML = 'Weather data not available';
                        document.getElementById('weather_info').style.display = 'block';
                    }
                })
                .catch(error => {
                    console.error('Error fetching weather:', error);
                    document.getElementById('weather_data').innerHTML = 'Error fetching weather data';
                    document.getElementById('weather_info').style.display = 'block';
                });


        }
    }
</script>

</body>
</html>