Repository navigation
Expand file tree
/
Copy pathindex.js
More file actions
110 lines (104 loc) · 3.02 KB
/
Copy pathindex.js
File metadata and controls
110 lines (104 loc) · 3.02 KB
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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
const express = require('express');
const app=express();
const PORT=80;
//Rota principal
app.get('/', (req,res) => {
res.send(`
<!DOCTYPE html>
<html>
<head>
<script src="manipulaNome.js" type="text/javascript" async></script>
<title>Catálogo de Heróis</title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
</head>
<body>
<h1>Catálogo de Heróis</h1>
<div>
<p>Bem-vindo ao seu catalogo definito de heróis.</p>
<a href="/marvel">Marvel</a>
<br>
<a href="/dc">DC</a>
<hr>
<a href="/personagem/DC/Flash">Flash</a>
<br>
<a href="/personagem/DC/Batman">Batman</a>
<br>
<a href="/personagem/Marvel/Thor">Thor</a>
<br>
<a href="/personagem/Marvel/Hulk">Hulk</a>
</div>
</body>
</html>
`);
});
app.get('/marvel', (req, res) => {
res.send(`<!DOCTYPE html>
<html>
<head>
<script src="manipulaNome.js" type="text/javascript" async></script>
<title>Catálogo de Heróis</title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
</head>
<body>
<h1>Marvel</h1>
<div>
<p>Bem-vindo ao seu catalogo definito de heróis da Marvel.</p>
<a href="/personagem/Marvel/Thor">Thor</a>
<br>
<a href="/personagem/Marvel/Hulk">Hulk</a>
<br>
<a href="/">Voltar</a>
</div>
</body>
</html>`);
});
app.get('/dc', (req, res)=>{
res.send(`<!DOCTYPE html>
<html>
<head>
<script src="manipulaNome.js" type="text/javascript" async></script>
<title>Catálogo de Heróis</title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
</head>
<body>
<h1>Catálogo de Heróis a DC</h1>
<div>
<p>Bem-vindo ao seu catalogo definito de heróis da DC.</p>
<a href="/personagem/DC/Flash">Flash</a>
<br>
<a href="/personagem/DC/Batman">Batman</a>
<br>
<a href="/">Voltar</a>
</div>
</body>
</html>`);
})
app.get('/personagem/:empresa/:nome', (req, res) => {
const { empresa, nome } = req.params;
res.send(`<!DOCTYPE html>
<html>
<head>
<script src="manipulaNome.js" type="text/javascript" async></script>
<title>Catálogo de Heróis</title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
</head>
<body>
<h1>${empresa} - ${nome}</h1>
<div>
<a href="/${empresa}">${empresa}</a>
<br>
<a href="/">Início</a>
<hr>
</div>
</body>
</html>`);
});
//Inicia servidor
app.listen(PORT, () => {
console.log(`Servidor rodando em http://localhost:${PORT}`);
});
//console.log("Servidor Node está funcionando!");