-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.html
215 lines (188 loc) · 7.13 KB
/
main.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
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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Heart Disease Prediction</title>
<style>
body {
background: url('imageheart1.jpg');
background-repeat: no-repeat;
background-size: cover;
color: #333;
font-family: Arial, sans-serif;
margin: 0;
padding: 20px;
height: 108vh;
}
.container{
display: flex;
justify-content:flex-start;
align-items: center;
}
h1 {
text-align: center;
color: #1f497d;
}
.form {
background-color:#2C2C2C;
/* Adjust alpha value as needed */
border-radius: 10px;
padding: 20px;
box-shadow: 0 0 10px rgba(237, 5, 5, 0.7);
width: 25%;
}
.imageContainer{
height: 96vh;
}
label {
display: block;
margin-bottom: 8px;
color: #fff;
font-weight: bold; /* Added bold font weight */
}
input,
select,
textarea {
width: calc(100% - 22px); /* Adjusted width to account for padding and border */
padding: 5px;
margin-bottom: 10px;
box-sizing: border-box;
border: 1px solid #ccc;
border-radius: 5px;
}
button {
background-color: rgb(238, 82, 82);
font-size: 20px;
color: #fff;
padding: 10px 20px;
border: none;
border-radius: 5px;
cursor: pointer;
}
button:hover {
background-color: #405580;
}
textarea {
resize: vertical;
}
.btn{
display: flex;
justify-content: flex-end;
margin-right: 17px;
}
.report{
display: none;
background-color: rgb(238, 82, 82);
font-size: 20px;
color: #fff;
padding: 10px 20px;
border: none;
border-radius: 5px;
cursor: pointer;
}
.buttonFlex{
display: flex;
}
</style>
</head>
<body>
<div class="container">
<div class="form">
<form id="chatbotForm" onsubmit="predict(); return false;">
<!-- Labels and Entry widgets for input -->
<label for="Age">Age:</label>
<input type="text" id="Age" required>
<label for="Sex">Sex:</label>
<select id="Sex" required>
<option value="M">M</option>
<option value="F">F</option>
</select>
<label for="RestingBP">Resting BP:</label>
<input type="text" id="RestingBP" required>
<label for="Cholesterol">Cholesterol:</label>
<input type="text" id="Cholesterol" required>
<label for="FastingBS">Fasting BS:</label>
<input type="text" id="FastingBS" required>
<label for="RestingECG">Resting ECG:</label>
<select id="RestingECG">
<option value="Normal">Normal</option>
<option value="ST">ST</option>
<option value="Lvh">Lvh</option>
</select>
<label for="MaxHR">Max HR:</label>
<input type="text" id="MaxHR" required>
<label for="ExerciseAngina">Exercise Angina:</label>
<select id="ExerciseAngina">
<option value="Y">Y</option>
<option value="N">N</option>
</select>
<label for="Oldpeak">Oldpeak:</label>
<input type="text" id="Oldpeak" required>
<label for="ST_Slope">ST Slope:</label>
<select id="ST_Slope">
<option value="Up">Up</option>
<option value="Flat">Flat</option>
<option value="Down">Down</option>
</select>
<!-- Result text area -->
<label for="result">Result:</label>
<textarea id="result" rows="2" cols="30" readonly></textarea>
<!-- Submit button -->
<div class="buttonFlex">
<div class="btn">
<button id="submitButton" type="submit">Submit</button>
</div>
<div class="report" id="reportid">
<a href="./frontend/report.html" style="text-decoration: none; color: white;">Report</a>
</div>
</div>
</form>
</div>
</div>
<script>
function predict() {
// Collect input values from the form
var input_values = {
'Age': parseFloat(document.getElementById('Age').value),
'Sex': document.getElementById('Sex').value,
'RestingBP': parseFloat(document.getElementById('RestingBP').value),
'Cholesterol': parseFloat(document.getElementById('Cholesterol').value),
'FastingBS': parseFloat(document.getElementById('FastingBS').value),
'RestingECG': document.getElementById('RestingECG').value,
'MaxHR': parseFloat(document.getElementById('MaxHR').value),
'ExerciseAngina': document.getElementById('ExerciseAngina').value,
'Oldpeak': parseFloat(document.getElementById('Oldpeak').value),
'ST_Slope': document.getElementById('ST_Slope').value
};
var input_values_string = JSON.stringify(input_values);
// Set the string in localStorage with a key
localStorage.setItem('input_values', input_values_string);
// Make a request to the server for prediction
// Replace 'http://localhost:5000/predict' with your actual server endpoint
var api_url = 'http://localhost:5000/predict';
// Use fetch API to make a POST request
fetch(api_url, {
method: 'POST',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify({'new_record': input_values})
})
.then(response => response.json())
.then(predictions => {
var result_text = "Predicted Chest Pain Type: " + predictions.predicted_chest_pain_type + ", Heart Patient: " + predictions.predicted_patient_has_disease;
document.getElementById('result').value = result_text;
localStorage.setItem("type",predictions.predicted_chest_pain_type)
localStorage.setItem("desesesFlag",predictions.predicted_patient_has_disease);
document.getElementById('reportid').style.display="block"
})
.catch(error => {
console.error('Error:', error);
document.getElementById('result').value = "Error: " + error.message;
});
}
</script>
</body>
</html>