forked from jplip/self-care-front
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathZ_depression.html
132 lines (119 loc) · 3.36 KB
/
Z_depression.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
---
layout: base
title: Depression
permalink: /depression
---
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Depression</title>
<style>
body {
font-family: Arial, sans-serif;
margin: 0;
padding: 0;
background-image: url("enter");
background-position: 50% 0;
background-size: cover;
background-attachment: fixed;
background-repeat: no-repeat;
}
.container {
background-color: rgba(255, 255, 255, 0.8);
padding: 20px;
border-radius: 8px;
box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
margin: 20px;
}
.form-control {
margin-bottom: 15px;
}
.form-control label {
font-weight: bold;
}
.form-control input {
width: 100%;
padding: 8px;
border: 1px solid #ccc;
border-radius: 4px;
box-sizing: border-box;
}
.form-control button {
background-color: #4CAF50;
color: white;
cursor: pointer;
padding: 10px 20px;
border: none;
border-radius: 4px;
transition: background-color 0.3s;
}
.form-control button:hover {
background-color: #45a049;
}
.result {
margin-top: 20px;
font-weight: bold;
}
/* Style for home button */
#homeButton {
position: fixed;
top: 20px;
left: 20px;
font-size: 16px;
text-decoration: none;
color: #333;
padding: 5px 10px;
border: 1px solid #ccc;
border-radius: 4px;
background-color: #f2f2f2;
}
</style>
<!-- Home button linking to index.html -->
<a id="homeButton" href="index">Home</a>
<div class="container">
<h1>Depression</h1>
<form>
<div class="form-control">
<label for="age">Age:</label>
<input id="age" type="number">
</div>
<div class="form-control">
<label for="stress">Stress Level:</label>
<input id="stress" type="number">
</div>
<div class="form-control">
<label for="exercise">Daily Exercise (Hours):</label>
<input id="exercise" type="number">
</div>
<div class="form-control">
<label for="sleep">Daily Sleep (Hours):</label>
<input id="sleep" type="number">
</div>
</form>
<button onclick="predict()" class="form-control">Submit</button>
<p class="result" id="depressed"></p>
</div>
<script>
function predict() {
var data = {
"age": parseFloat(document.getElementById("age").value),
"stress": parseFloat(document.getElementById("stress").value),
"exercise": parseFloat(document.getElementById("exercise").value),
"sleep": parseFloat(document.getElementById("sleep").value),
};
var options = {
method: "POST",
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify(data)
};
fetch("http://127.0.0.1:8432/api/predict/", options)
.then(response => response.json())
.then(result => {
document.getElementById("depressed").innerHTML = result;
})
.catch(error => {
console.error('Error:', error);
});
}
</script>