-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.js
46 lines (42 loc) · 1.52 KB
/
index.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
const express = require("express");
const path = require("path");
const app = express();
const exphbs = require("express-handlebars");
const PORT = process.env.PORT || 4000;
app.engine(
".hbs",
exphbs.engine({
extname: ".hbs",
helpers: {
formatearNumber: function (numberString) {
return (+numberString).toLocaleString();
},
primeraMayuscula: function (texto) {
return texto.charAt(0).toUpperCase() + texto.slice(1);
},
boldHeroTitle: function (options) {
return '<h1 class="fw-bold">' + options.fn(this) + "</h1>";
},
},
})
);
app.set("view engine", ".hbs");
app.set("views", "./views");
app.listen(PORT, () => {
console.log(`El servidor está inicializado en el puerto ${PORT}`);
});
app.use("/bootstrap_css", express.static("./node_modules/bootstrap/dist/css"));
app.use("/bootstrap_js", express.static("./node_modules/bootstrap/dist/js"));
app.use("/jquery", express.static("./node_modules/jquery/dist"));
app.use("/public", express.static("./public"));
const datos = [
{ articulo: "banana", precio: "1500", medida: "1", unidad: "kg" },
{ articulo: "cebollas", precio: "100", medida: "1", unidad: "unidad" },
{ articulo: "lechuga", precio: "500", medida: "1", unidad: "unidad" },
{ articulo: "papas", precio: "2000", medida: "3", unidad: "kg" },
{ articulo: "pimenton", precio: "500", medida: "1", unidad: "unidad" },
{ articulo: "tomate", precio: "800", medida: "1", unidad: "kg" },
];
app.get("/", (req, res) => {
res.render("inicio", { datos });
});