-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
168 lines (149 loc) · 5.06 KB
/
index.html
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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title><b>House Price Prediction</b></title>
<!-- Add your CSS styles or include external stylesheets here -->
<style>
/* Add your styles here */
body {
font-family: 'Times New Roman', Times, serif, Haettenschweiler, 'Arial Narrow Bold', sans-serif, sans-serif;
margin: 0;
padding: 0;
background-color: #f5e7dc;
}
header {
background-color: #54bce5;
color: #fff;
padding: 10px;
text-align: center;
}
main {
max-width: 800px;
margin: 20px auto;
padding: 20px;
background-color: #54bce5;
box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
}
footer {
text-align: center;
padding: 10px;
background-color: #f97474;
color: #fff;
position: fixed;
bottom: 0;
width: 100%;
}
/* Add styling for the form */
form {
margin-top: 20px;
}
label {
display: block;
margin-bottom: 8px;
}
select {
width: 100%;
padding: 8px;
margin-bottom: 16px;
}
button {
background-color: #333;
color: #fff;
padding: 10px;
border: none;
cursor: pointer;
}
/* Style for displaying the predicted price */
#predictedPrice {
margin-top: 20px;
font-weight: bold;
}
</style>
</head>
<body>
<header>
<h1>House Price Prediction</h1>
</header>
<main>
<p><i>Welcome to House Price Prediction Model!</i></p>
<!-- Form for input fields -->
<form id="predictionForm">
<label for="beds">Bedrooms:</label>
<select id="beds" name="beds">
<option value="" disabled selected>Select number of bedrooms</option>
{% for bedroom in bedrooms %}
<option value="{{ bedroom }}">{{ bedroom }}</option>
{% endfor %}
</select>
<label for="baths">Baths:</label>
<select id="baths" name="baths">
<option value="" disabled selected>Select number of bathrooms</option>
{% for bathroom in bathrooms %}
<option value="{{ bathroom }}">{{ bathroom }}</option>
{% endfor %}
</select>
<label for="size">Size:</label>
<select id="size" name="size">
<option value="" disabled selected>Select size of the house</option>
{% for house_size in sizes %}
<option value="{{ house_size }}">{{ house_size }} sqft</option>
{% endfor %}
</select>
<label for="zip_code">Zip Code:</label>
<select id="zip_code" name="zip_code">
<option value="" disabled selected>Select zip code</option>
{% for zip_code in zip_codes %}
<option value="{{ zip_code }}">{{ zip_code }}</option>
{% endfor %}
</select>
<!-- Predict Price button -->
<button type="button" onclick="sendData()">Predict Price</button>
<!-- Space for displaying predicted price -->
<div id="predictedPrice"></div>
</form>
</main>
<footer>
<p>© 2024 House Price Prediction. All rights reserved.</p>
</footer>
<!-- Add your JavaScript scripts or include external scripts here -->
<script>
// JavaScript function to fetch options for dropdowns
function fetchOptions(endpoint, dropdownId) {
fetch(endpoint)
.then(response => response.json())
.then(data => {
const dropdown = document.getElementById(dropdownId);
dropdown.innerHTML = '<option value="" disabled selected>Select an option</option>';
data.forEach(option => {
const optionElement = document.createElement('option');
optionElement.value = option;
optionElement.textContent = option;
dropdown.appendChild(optionElement);
});
});
}
// Fetch options for each dropdown on page load
window.onload = function() {
fetchOptions('/bedrooms', 'beds');
fetchOptions('/bathrooms', 'baths');
fetchOptions('/sizes', 'size');
fetchOptions('/zip_codes', 'zip_code');
};
// JavaScript function to send data and receive predicted price
function sendData() {
const form = document.getElementById('predictionForm');
const formData = new FormData(form);
fetch('/predict', {
method: 'POST',
body: formData
})
.then(response => response.text())
.then(price => {
document.getElementById("predictedPrice").innerHTML = "Price: INR " + price;
});
}
</script>
</body>
</html>