Hands On Lab
Hands On Lab
Criar o front-end
Crie a pasta public
-- mkdir public
Crie o arquivo index.html (dentro da pasta public), usando as linhas a seguir
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Simple Web App</title>
<link rel="stylesheet" href="styles.css">
</head>
<body>
<h1>Enter Your Details</h1>
<form id="userForm">
<label for="name">Name:</label>
<input type="text" id="name" name="name" required><br><br>
<label for="email">Email:</label>
<input type="email" id="email" name="email" required><br><br>
<label for="age">Age:</label>
<input type="number" id="age" name="age" required><br><br>
<button type="submit">Submit</button>
</form>
<p id="responseMessage"></p>
<script src="script.js"></script>
</body>
</html>
Crie o arquivo css (styles.css dentro da pasta public)
body {
font-family: Arial, sans-serif;
max-width: 600px;
margin: 0 auto;
padding: 20px;
}
h1 {
color: #333;
}
form {
display: flex;
flex-direction: column;
}
input {
padding: 10px;
margin-bottom: 15px;
border: 1px solid #ccc;
border-radius: 5px;
}
button {
padding: 10px;
background-color: #28a745;
color: white;
border: none;
border-radius: 5px;
cursor: pointer;
}
button:hover {
background-color: #218838;
}
#responseMessage {
margin-top: 20px;
font-weight: bold;
}
Crie o script.js (dentro da pasta public)
document.getElementById('userForm').addEventListener('submit', async
function(event) {
event.preventDefault();