File size: 4,160 Bytes
e0a433a
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>House Price Predictor</title>
    <link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet">
    <style>
        body {
            padding: 20px;
            background-color: #f8f9fa;
        }
        .container {
            max-width: 800px;
            background-color: white;
            padding: 30px;
            border-radius: 10px;
            box-shadow: 0 0 10px rgba(0,0,0,0.1);
            margin-top: 50px;
        }
        .prediction-result {
            margin-top: 20px;
            padding: 20px;
            border-radius: 5px;
            background-color: #e9ecef;
        }
        .property-details {
            margin-top: 20px;
            padding: 15px;
            border: 1px solid #dee2e6;
            border-radius: 5px;
        }
    </style>
</head>
<body>
    <div class="container">
        <h2 class="text-center mb-4">Bangalore House Price Predictor</h2>
        
        {% if error %}
        <div class="alert alert-danger" role="alert">
            {{ error }}
        </div>
        {% endif %}
        
        <form method="POST" class="needs-validation" novalidate>
            <div class="mb-3">
                <label for="location" class="form-label">Location:</label>
                <select class="form-select" id="location" name="location" required>
                    <option value="">Select a location</option>
                    {% for location in locations %}
                    <option value="{{ location }}">{{ location }}</option>
                    {% endfor %}
                </select>
            </div>

            <div class="mb-3">
                <label for="sqft" class="form-label">Total Square Feet:</label>
                <input type="number" class="form-control" id="sqft" name="sqft" min="100" required>
            </div>

            <div class="mb-3">
                <label for="bath" class="form-label">Number of Bathrooms:</label>
                <input type="number" class="form-control" id="bath" name="bath" min="1" max="10" required>
            </div>

            <div class="mb-3">
                <label for="bhk" class="form-label">BHK (Bedrooms):</label>
                <input type="number" class="form-control" id="bhk" name="bhk" min="1" max="10" required>
            </div>

            <div class="text-center">
                <button type="submit" class="btn btn-primary">Predict Price</button>
            </div>
        </form>

        {% if prediction is not none %}
        <div class="prediction-result text-center">
            <h4>Predicted Price:</h4>
            <p class="h3">₹ {{ prediction }} Lakhs</p>
            
            {% if property_details %}
            <div class="property-details">
                <h5>Property Details:</h5>
                <ul class="list-unstyled">
                    <li><strong>Location:</strong> {{ property_details.location }}</li>
                    <li><strong>Area:</strong> {{ property_details.sqft }} sq.ft</li>
                    <li><strong>Bathrooms:</strong> {{ property_details.bath }}</li>
                    <li><strong>BHK:</strong> {{ property_details.bhk }}</li>
                </ul>
            </div>
            {% endif %}
        </div>
        {% endif %}
    </div>

    <script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js"></script>
    <script>
        // Form validation
        (function () {
            'use strict'
            var forms = document.querySelectorAll('.needs-validation')
            Array.prototype.slice.call(forms).forEach(function (form) {
                form.addEventListener('submit', function (event) {
                    if (!form.checkValidity()) {
                        event.preventDefault()
                        event.stopPropagation()
                    }
                    form.classList.add('was-validated')
                }, false)
            })
        })()
    </script>
</body>
</html>