forked from ilirt123/ECE528-website
-
Notifications
You must be signed in to change notification settings - Fork 0
/
sampleAPI.html
95 lines (75 loc) · 3.59 KB
/
sampleAPI.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
<!DOCTYPE html>
<html>
<head>
<title>Google Cloud API</title>
</head>
<body>
<h1>Google Cloud API</h1>
<form id="my-form">
<label for="feature_column_a">usmers:</label>
<input type="value" ><br>
<label for="feature_column_b">gender:</label>
<input type="value" ><br>
<label for="feature_column_b">patient type:</label>
<input type="text" id="feature_column_b" name="feature_column_b"><br>
<label for="feature_column_b">intubated:</label>
<input type="text" id="feature_column_b" name="feature_column_b"><br>
<label for="feature_column_b">pneumonia:</label>
<input type="text" id="feature_column_b" name="feature_column_b"><br>
<label for="feature_column_b">age:</label>
<input type="text" id="feature_column_b" name="feature_column_b"><br>
<label for="feature_column_b">calsification:</label>
<input type="text" id="feature_column_b" name="feature_column_b"><br>
<label for="feature_column_b">diabetes:</label>
<input type="text" id="feature_column_b" name="feature_column_b"><br>
<label for="feature_column_b">medical_type:</label>
<input type="text" id="feature_column_b" name="feature_column_b"><br>
<label for="feature_column_b">copd:</label>
<input type="text" id="feature_column_b" name="feature_column_b"><br>
<label for="feature_column_b">asthma:</label>
<input type="text" id="feature_column_b" name="feature_column_b"><br>
<label for="feature_column_b">inmsupr:</label>
<input type="text" id="feature_column_b" name="feature_column_b"><br>
<label for="feature_column_b">hypertension:</label>
<input type="text" id="feature_column_b" name="feature_column_b"><br>
<label for="feature_column_b">other_disease:</label>
<input type="text" id="feature_column_b" name="feature_column_b"><br>
<label for="feature_column_b">cardiovascular:</label>
<input type="text" id="feature_column_b" name="feature_column_b"><br>
<label for="feature_column_b">obesity:</label>
<input type="text" id="feature_column_b" name="feature_column_b"><br>
<label for="feature_column_b">renal_chronic:</label>
<input type="text" id="feature_column_b" name="feature_column_b"><br>
<label for="feature_column_b">tobacho:</label>
<input type="text" id="feature_column_b" name="feature_column_b"><br>
<label for="feature_column_b">icu:</label>
<input type="text" id="feature_column_b" name="feature_column_b"><br>
<button type="submit">Submit</button>
</form>
<script src="https://unpkg.com/axios/dist/axios.min.js"></script>
<script>
const form = document.querySelector('#my-form');
form.addEventListener('submit', async (e) => {
e.preventDefault();
const data = {
instances: [
{
feature_column_a: form.feature_column_a.value,
feature_column_b: form.feature_column_b.value,
}
]
};
const projectId = 'ece528-website';
const endpointId = '1049492644805214208';
const accessToken = '4/0AWtgzh5ElIpsOWzGJWfXITmN16A4GVnGb0_HYkGS0L7GnnmGrHCLfrsVlFejeQpPxADkIg';
const url = `https://us-central1-aiplatform.googleapis.com/v1/projects/${projectId}/locations/us-central1/endpoints/${endpointId}:predict`;
const headers = {
Authorization: `Bearer ${'4/0AWtgzh5ElIpsOWzGJWfXITmN16A4GVnGb0_HYkGS0L7GnnmGrHCLfrsVlFejeQpPxADkIg'}`,
'Content-Type': 'application/json',
};
const response = await axios.post(url, data, { headers });
console.log(response.data);
});
</script>
</body>
</html>