-
Notifications
You must be signed in to change notification settings - Fork 125
/
server.js
48 lines (37 loc) · 968 Bytes
/
server.js
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
const express = require('express');
const app = express();
const port = 3000;
const constructPageBody = require('./checkOrder');
const pageHead =
`
<!DOCTYPE html>
<html lang="ru">
<head>
<title>Результат заказа питомца</title>
<link rel="stylesheet" href="/styles.css">
</head>
<body>
<main>
<h1>Результат заказа питомца</h1>
`;
const pageFoot =
`
<a href="/">⃪ Вернуться к форме заказа</a>
</main>
</body>
</html>
`;
app.listen(port, (err) => {
if (err) {
return console.log('something bad happened', err);
}
console.log(`server is listening on ${port}`);
});
app.use(express.static('static'));
app.use(express.urlencoded({ extended: true }));
app.post('/pets/orders', (request, response) => {
const reqBody = request.body;
const pageBody = constructPageBody(reqBody);
console.log(request.body);
response.send(`${pageHead}${pageBody}${pageFoot}`);
});