made responsive
Browse files- 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
|
| 7 |
<link href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css" rel="stylesheet">
|
| 8 |
<style>
|
| 9 |
body {
|
| 10 |
-
background-color: #
|
|
|
|
| 11 |
}
|
| 12 |
-
.
|
| 13 |
-
|
| 14 |
-
|
| 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 |
-
|
| 26 |
-
color: #28a745;
|
| 27 |
-
text-align: center;
|
| 28 |
font-weight: bold;
|
| 29 |
}
|
| 30 |
-
.
|
| 31 |
-
|
| 32 |
-
|
| 33 |
-
height: 100%;
|
| 34 |
}
|
| 35 |
-
.
|
| 36 |
-
|
| 37 |
-
border-
|
| 38 |
-
|
| 39 |
}
|
| 40 |
-
.
|
| 41 |
-
|
| 42 |
-
|
| 43 |
-
|
| 44 |
-
|
| 45 |
-
|
| 46 |
-
|
|
|
|
| 47 |
}
|
| 48 |
-
|
| 49 |
-
|
| 50 |
-
|
| 51 |
-
|
|
|
|
| 52 |
}
|
| 53 |
.form-control {
|
| 54 |
border-color: #28a745;
|
| 55 |
-
background-color: #
|
| 56 |
}
|
| 57 |
.btn-green {
|
| 58 |
background-color: #28a745;
|
| 59 |
color: white;
|
| 60 |
font-weight: bold;
|
| 61 |
width: 100%;
|
| 62 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 63 |
}
|
| 64 |
</style>
|
| 65 |
</head>
|
| 66 |
<body>
|
| 67 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 68 |
<div class="container">
|
| 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 |
</div>
|
| 124 |
-
</
|
| 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 |
-
|
| 136 |
-
Weather
|
| 137 |
-
Temperature
|
| 138 |
-
Humidity
|
| 139 |
-
Pressure
|
| 140 |
`;
|
| 141 |
-
document.getElementById('weather_info').style.display = 'block';
|
| 142 |
} else {
|
| 143 |
-
|
| 144 |
-
document.getElementById('weather_info').style.display = 'block';
|
| 145 |
}
|
| 146 |
})
|
| 147 |
.catch(error => {
|
| 148 |
console.error('Error fetching weather:', error);
|
| 149 |
-
|
| 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>
|