-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.js
45 lines (37 loc) · 871 Bytes
/
app.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
const express = require("express");
const hbs = require("hbs");
require("dotenv").config();
const app = express();
const port = process.env.PORT;
// Handlebars
app.set("view engine", "hbs");
hbs.registerPartials(__dirname + "/views/partials");
// Servir contenido estático
app.use(express.static("public"));
app.get("/", (req, res) => {
res.render("home", {
nombre: "JSamuel",
titulo: "Curso de Node.js",
});
});
app.get("/elements", (req, res) => {
res.render("elements", {
nombre: "JSamuel",
titulo: "Curso de Node.js",
});
});
app.get("/generic", (req, res) => {
res.render("generic", {
nombre: "JSamuel",
titulo: "Curso de Node.js",
});
});
app.get("*", (req, res) => {
res.render("404", {
nombre: "JSamuel",
titulo: "Curso de Node.js",
});
});
app.listen(port, () => {
console.log(`App escuchando en http://localhost:${port}`);
});