Studying docker
1const express = require('express');
2const bodyParser = require('body-parser');
3
4const app = express();
5
6let userGoal = 'Learn Docker!';
7
8app.use(
9 bodyParser.urlencoded({
10 extended: false,
11 })
12);
13
14app.use(express.static('public'));
15
16app.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>ChAnGeD sTuFf</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
39app.post('/store-goal', (req, res) => {
40 const enteredGoal = req.body.goal;
41 console.log(enteredGoal);
42 userGoal = enteredGoal;
43 res.redirect('/');
44});
45
46app.listen(80);