File size: 8,461 Bytes
8752cbe
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Car Price Predictor</title>
    <style>

        body {

            background-image: url("/static/R.jpeg");

            background-size: cover;

            background-position: center;

            font-family: 'Segoe UI', Arial, sans-serif;

            /* background: linear-gradient(120deg, #4a83ed, #517fd6); */

            padding: 40px 0;

          

        }

        .container {

            max-width: 480px;

            background: #5dd9f4;

            padding: 32px 28px 28px 28px;

            border-radius: 16px;

            margin: auto;

            box-shadow: 0 8px 32px 0 rgba(31, 38, 135, 0.18);

            border: 1px solid #e3e3e3;

        }

        input, select {

            width: 100%;

            padding: 12px 10px;

            margin: 12px 0 18px 0;

            border: 1px solid #bfc9d1;

            border-radius: 6px;

            font-size: 1rem;

            background: #f8fafc;

            transition: border 0.2s;

        }

        input:focus, select:focus {

            border: 1.5px solid #007bff;

            outline: none;

        }

        button {

            background: linear-gradient(90deg, #007bff 60%, #28a745 100%);

            color: white;

            padding: 12px 0;

            border: none;

            border-radius: 6px;

            font-size: 1.1rem;

            font-weight: 600;

            width: 100%;

            cursor: pointer;

            box-shadow: 0 2px 8px rgba(0,123,255,0.08);

            transition: background 0.2s;

        }

        button:hover {

            background: linear-gradient(90deg, #0056b3 60%, #218838 100%);

        }

        h2 {

            color: #22223b;

            margin-bottom: 18px;

            text-align: center;

        }

        label {

            font-weight: 500;

            color: #495057;

        }

        .result {

            margin-top: 24px;

            padding: 18px 12px;

            background: #e7f9ed;

            border-left: 5px solid #28a745;

            border-radius: 6px;

            font-size: 1.2rem;

            color: #155724;

            font-weight: 600;

            text-align: center;

            min-height: 32px;

            opacity: 0;

            animation: fadeIn 1s forwards;

        }

        .result:not(:empty) {

            opacity: 1;

        }

        @keyframes fadeIn {

            from { opacity: 0; transform: translateY(20px); }

            to { opacity: 1; transform: translateY(0); }

        }

        .error {

            background: #ffeaea;

            border-left: 5px solid #dc3545;

            color: #721c24;

        }

        .spinner {

            display: none;

            margin: 0 auto 18px auto;

            border: 4px solid #f3f3f3;

            border-top: 4px solid #007bff;

            border-radius: 50%;

            width: 36px;

            height: 36px;

            animation: spin 1s linear infinite;

        }

        @keyframes spin {

            0% { transform: rotate(0deg); }

            100% { transform: rotate(360deg); }

        }

        input:hover, select:hover {

            background: #eef6fb;

            border-color: #007bff;

        }

        .tooltip {

            position: relative;

            display: inline-block;

            cursor: help;

        }

        .tooltip .tooltiptext {

            visibility: hidden;

            width: 180px;

            background-color: #22223b;

            color: #fff;

            text-align: center;

            border-radius: 6px;

            padding: 6px 8px;

            position: absolute;

            z-index: 1;

            bottom: 125%;

            left: 50%;

            margin-left: -90px;

            opacity: 0;

            transition: opacity 0.3s;

            font-size: 0.95rem;

        }

        .tooltip:hover .tooltiptext {

            visibility: visible;

            opacity: 1;

        }

        .footer {

            margin-top: 40px;

            text-align: center;

            color: #888;

            font-size: 0.98rem;

            letter-spacing: 0.5px;

        }

        @media (max-width: 600px) {

            .container { padding: 18px 6px; }

        }

    </style>
</head>
<body>
    <div class="container">
        <h2>Car Price Predictor</h2>
        <form method="post" autocomplete="off" id="predictForm" onsubmit="showSpinner()">
            <label for="present_price">Present Price (in Lakhs)
                <span class="tooltip">&#9432;
                    <span class="tooltiptext">Current ex-showroom price of the car in lakhs (e.g. 5.5)</span>
                </span>
            </label>
            <input type="number" step="0.01" min="0" name="present_price" id="present_price" placeholder="e.g. 5.5" required>

            <label for="kms_driven">Kilometers Driven
                <span class="tooltip">&#9432;
                    <span class="tooltiptext">Total distance the car has been driven (e.g. 35000)</span>
                </span>
            </label>
            <input type="number" min="0" name="kms_driven" id="kms_driven" placeholder="e.g. 35000" required>

            <label for="owner">Number of Owners
                <span class="tooltip">&#9432;
                    <span class="tooltiptext">How many people have owned the car?</span>
                </span>
            </label>
            <select name="owner" id="owner" required>
                <option value="0">0 (First Owner)</option>
                <option value="1">1 (Second Owner)</option>
                <option value="3">3 (Third Owner or more)</option>
            </select>

            <label for="car_age">Car Age (Years)
                <span class="tooltip">&#9432;
                    <span class="tooltiptext">How old is the car? (e.g. 5)</span>
                </span>
            </label>
            <input type="number" min="0" max="30" name="car_age" id="car_age" placeholder="e.g. 5" required>

            <label for="fuel_type">Fuel Type
                <span class="tooltip">&#9432;
                    <span class="tooltiptext">Select the car's fuel type</span>
                </span>
            </label>
            <select name="fuel_type" id="fuel_type" required>
                <option value="Petrol">Petrol</option>
                <option value="Diesel">Diesel</option>
                <option value="LPG">LPG</option>
            </select>

            <label for="company">Company
                <span class="tooltip">&#9432;
                    <span class="tooltiptext">Select the car's manufacturer</span>
                </span>
            </label>
            <select name="company" id="company" required>
                <option value="Hyundai">Hyundai</option>
                <option value="Ford">Ford</option>
                <option value="Mahindra">Mahindra</option>
                <option value="Maruti">Maruti</option>
                <option value="Honda">Honda</option>
                <option value="Toyota">Toyota</option>
                <option value="Volkswagen">Volkswagen</option>
                <option value="Tata">Tata</option>
            </select>

            <div style="display: flex; gap: 10px;">
                <button type="submit" style="flex:1;">Predict Car Price</button>
                <button type="reset" style="flex:1; background: #6c757d;">Reset</button>
            </div>
        </form>
        <div class="spinner" id="spinner"></div>
        <div class="result {% if 'Error' in prediction_text %}error{% endif %}" id="resultBox">
            {{ prediction_text }}
        </div>
        <div class="footer">
            &copy; 2025 Car Price Predictor | Powered by Machine Learning
        </div>
        <script>

            function showSpinner() {

                document.getElementById('spinner').style.display = 'block';

                document.getElementById('resultBox').style.opacity = 0.5;

            }

            document.getElementById('predictForm').addEventListener('reset', function() {

                setTimeout(function() {

                    document.getElementById('resultBox').innerHTML = '';

                }, 100);

            });

        </script>
    </div>
</body>
</html>