-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
56 lines (43 loc) · 1.79 KB
/
index.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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Poke</title>
</head>
<body>
<!-- <form method="POST" action="/my_endpoint">
<label for="my_field">My Field:</label>
<input type="text" id="my_field" name="password">
</form> -->
<h1>Your ingredients</h1>
<p id="paragraph"></p>
<button onclick="retrieveArray()">Submit</button>
<p id="result"></p>
</body>
<script>
const myArray = ["riso bianco", "salmone crudo", "tonno crudo", "daikon", "zenzero marinato", "uovo marinato", "edamame", "semi di lino"];
document.getElementById("paragraph").innerHTML = myArray;
function retrieveArray() {
console.log("retrieveArray");
// const myArray = document.getElementById("ingredienti").value;
const requestOptions = {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ password: 'Phaser2023', recipe_incomplete: myArray})
// body: JSON.stringify({ recipe_incomplete: myArray })
};
const queryString = window.location.search;
const urlParams = new URLSearchParams(queryString);
const recipe_incomplete = urlParams.get('myArray');
fetch('http://raffaella94.pythonanywhere.com/api/v.1.0/backend_recipe_predict', requestOptions)
//fetch('http://127.0.0.1:8080/api/v.1.0/backend_recipe_predict', requestOptions)
.then(response => response.json())
.then(data => {
console.log(data);
document.getElementById('result').innerHTML += data[8];
document.getElementById('result').innerHTML += ", " + data[9];
})
}
</script>
</html>