-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathjavascipt.js
More file actions
27 lines (26 loc) · 852 Bytes
/
Copy pathjavascipt.js
File metadata and controls
27 lines (26 loc) · 852 Bytes
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
const cognitiveTestForm = document.getElementById('cognitive-test');
const resultDiv = document.getElementById('result');
cognitiveTestForm.addEventListener('submit', (e) => {
e.preventDefault();
const files = [];
for (let i = 1; i <= 3; i++) {
const fileInput = document.getElementById(`file${i}`);
files.push(fileInput.files[0]);
}
// Send files to server for prediction
fetch('/predict', {
method: 'POST',
body: JSON.stringify(files),
headers: {
'Content-Type': 'application/json'
}
})
.then(response => response.json())
.then((data) => {
const result = data.prediction;
resultDiv.innerText = `Based on your cognitive test results, you are at risk of ${result}.`;
})
.catch((error) => {
console.error(error);
});
});