Skip to content

Commit 4281e8c

Browse files
committed
não sei bem
1 parent be8dfd8 commit 4281e8c

File tree

4 files changed

+106
-0
lines changed

4 files changed

+106
-0
lines changed

.DS_Store

6 KB
Binary file not shown.

package.json

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{
2+
"name": "docker-complete",
3+
"version": "1.0.0",
4+
"description": "",
5+
"main": "server.js",
6+
"author": "Maximilian Schwarzmüller / Academind GmbH",
7+
"license": "MIT",
8+
"dependencies": {
9+
"express": "^4.17.1",
10+
"body-parser": "1.19.0"
11+
}
12+
}

public/styles.css

+48
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
html {
2+
font-family: sans-serif;
3+
}
4+
5+
body {
6+
margin: 0;
7+
}
8+
9+
section,
10+
form {
11+
padding: 1rem;
12+
border-radius: 12px;
13+
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.26);
14+
margin: 2rem auto;
15+
max-width: 40rem;
16+
}
17+
18+
.form-control {
19+
margin: 0.5rem 0;
20+
}
21+
22+
input {
23+
font: inherit;
24+
}
25+
26+
input,
27+
label {
28+
display: block;
29+
}
30+
31+
label {
32+
font-weight: bold;
33+
margin-bottom: 0.5rem;
34+
}
35+
36+
button {
37+
background-color: #2f005a;
38+
border: 1px solid #2f005a;
39+
color: white;
40+
cursor: pointer;
41+
padding: 0.5rem 1.5rem;
42+
}
43+
44+
button:hover,
45+
button:active {
46+
background-color: #50005a;
47+
border-color: #50005a;
48+
}

server.js

+46
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
const express = require('express');
2+
const bodyParser = require('body-parser');
3+
4+
const app = express();
5+
6+
let userGoal = 'Learn Docker!';
7+
8+
app.use(
9+
bodyParser.urlencoded({
10+
extended: false,
11+
})
12+
);
13+
14+
app.use(express.static('public'));
15+
16+
app.get('/', (req, res) => {
17+
res.send(`
18+
<html>
19+
<head>
20+
<link rel="stylesheet" href="styles.css">
21+
</head>
22+
<body>
23+
<section>
24+
<h2>My Course Goal</h2>
25+
<h3>${userGoal}</h3>
26+
</section>
27+
<form action="/store-goal" method="POST">
28+
<div class="form-control">
29+
<label>Course Goal</label>
30+
<input type="text" name="goal">
31+
</div>
32+
<button>Set Course Goal</button>
33+
</form>
34+
</body>
35+
</html>
36+
`);
37+
});
38+
39+
app.post('/store-goal', (req, res) => {
40+
const enteredGoal = req.body.goal;
41+
console.log(enteredGoal);
42+
userGoal = enteredGoal;
43+
res.redirect('/');
44+
});
45+
46+
app.listen(80);

0 commit comments

Comments
 (0)