-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
32 lines (28 loc) · 1008 Bytes
/
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
const express = require("express");
const app = express();
const port = process.env.PORT || 4000;
const expressHbs = require("express-handlebars");
//cau hinh tra ve thu muc web tinh
app.use(express.static(__dirname + "/html"));
//cau hinh su dung view template
app.engine(
"hbs",
expressHbs.engine({
layoutsDir: __dirname + "/views/layouts",
partialsDir: __dirname + "/views/partials",
extname: "hbs",
defaultLayout: "layout",
})
);
app.set("view engine","hbs");
app.get("/",(req,res) => {res.render("index")});
app.use("/task1.htm", require("./routes/task1Route"))
app.use("/task2.htm", require("./routes/task2Route"))
app.use("/task3.htm", require("./routes/task3Route"))
app.use("/task4.htm", require("./routes/task4Route"))
// app.use("/task4-details.htm",require("./routes/task4-detailsRoute"));
app.get("/admin",(req,res) => {
res.render("index", {layout: "admin"})
})
app.listen(port, () => console.log(`Example app
listening on port ${port}!`));