-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.js
More file actions
51 lines (49 loc) · 1.2 KB
/
app.js
File metadata and controls
51 lines (49 loc) · 1.2 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
const path = require("path");
const express = require("express");
const app = express();
const publicDir = path.join(__dirname, "../public");
const viewsPath = path.join(__dirname, "../templates/views");
const partialsPath = path.join(__dirname, "../templates/partials");
app.use(express.static(publicDir));
app.set("view engine", "hbs");
app.set("views", view);
hbs.registerPartials(partialsPath);
app.get("", (req, res) => {
res.render("index", {
title: "weather app",
name: "kyel chung",
});
});
app.get("/about", (req, res) => {
res.render("about", {
title: "about",
about: "about ME",
name: "kyle",
});
});
app.get("", (req, res) => {
res.send("<h1>Home Page </h1>");
});
app.get("/help", (req, res) => {
res.render("help", {
something: "someting wrong",
or: "Or something Confuse?",
name: "kyle",
});
});
app.get("/weather", (req, res) => {
res.send("Weather is ...");
});
app.get("/help/*", (req, res) => {
res.send("help article not found");
});
app.get("*", (req, res) => {
res.render("404", {
title: "404",
name: "kyel chung",
errorMessage: "page not found",
});
});
app.listen(3000, () => {
console.log("server is setting up on port 3000");
});