-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
51 lines (48 loc) · 1.73 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
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Sorteio Automático</title>
<!-- Estilização da página -->
<link rel="stylesheet" href="styles.css">
<script>
// Função para chamar a API
var realizarSorteio = (nomeSorteio, numMin, numMax) => {
var myHeaders = new Headers();
myHeaders.append("Content-Type", "application/json");
var raw = JSON.stringify({
"nomeSorteio": nomeSorteio,
"numMin": numMin,
"numMax": numMax
});
var requestOptions = {
method: 'POST',
headers: myHeaders,
body: raw,
redirect: 'follow'
};
fetch("https://ampeby30xh.execute-api.us-east-1.amazonaws.com/prod/", requestOptions)
.then(response => response.text())
.then(result => alert("Número sorteado: " + JSON.parse(JSON.parse(result).body).numeroSorteado))
.catch(error => console.log('error', error));
}
</script>
</head>
<body>
<h1>Bem-vindo ao Sorteio Automático!</h1>
<form>
<label>Nome do sorteio:</label>
<input type="text" id="nomeSorteio"><br>
<label>Número Mínimo:</label>
<input type="number" id="numMin"><br>
<label>Número Máximo:</label>
<input type="number" id="numMax"><br>
<!-- Botão que chama a função realizarSorteio -->
<button type="button" onclick="realizarSorteio(
document.getElementById('nomeSorteio').value,
document.getElementById('numMin').value,
document.getElementById('numMax').value
)">Realizar Sorteio</button>
</form>
</body>
</html>