-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathapp.js
88 lines (80 loc) · 2.41 KB
/
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
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
"use strict";
const express = require("express");
const app = express();
const names = ["Moe", "Larry", "Barbabra"];
app.set("view engine", "pug");
app.use(express.static(__dirname + "/public"));
app.use(
"/bootstrap",
express.static(__dirname + "/node_modules/bootstrap/dist/")
);
app.get("/", (req, res, next) => {
let homeData = {
subtitle: "This came from my JS data",
names,
showMe: true
// setShowMe: () => {console.log("Clicked") this.showMe = false}
};
res.render("index", homeData);
});
app.get("/article", (req, res, next) => {
res.render("article", {
subtitle: "This came from my JS data",
names
});
});
let nationalParks = {
AK: {
state: "Alaska",
parks: [{ name: "Cold Stuff Place" }, { name: "Brrrrr Nat'l Park" }]
},
AR: {
state: "Arkansas",
parks: [
{ name: "Paddle Faster Refuge" },
{ name: "Dueling Banjos Nat'l Monument" }
]
},
AZ: { state: "Arizona", parks: [] },
CA: { state: "California", parks: [] },
CO: { state: "Colorado", parks: [] },
FL: { state: "Florida", parks: [] },
HI: { state: "Hawaii", parks: [{ name: "Surf's Up National Seashore" }] },
ID: { state: "Idaho", parks: [{ name: "World's Biggest Tater Park" }] },
KY: { state: "Kentucky", parks: [] },
ME: { state: "Maine", parks: [] },
MI: { state: "Michigan", parks: [] },
MN: { state: "Minnesota", parks: [] },
MT: { state: "Montana", parks: [] },
TN: {
state: "Tennessee",
parks: [{ name: "Rush Hour Gridlock Picnic Area" }]
},
ND: { state: "North Dakota", parks: [] },
NM: { state: "New Maexico", parks: [] },
NV: { state: "Nevada", parks: [] },
OH: {
state: "Ohio",
parks: [{ name: "Flat 'n Boring Park" }, { name: "Filthy Lakes Beach" }]
},
OR: { state: "Oregon", parks: [] },
SC: { state: "South Carolina", parks: [] },
SD: {
state: "South Dakota",
parks: [{ name: "Dead White Guys National Park" }]
},
TX: { state: "Texas", parks: [] },
UT: { state: "Utah", parks: [] },
VA: { state: "Virginia", parks: [] },
VI: {
state: "Virgin Islands",
parks: [{ name: "Worst Ski Resort Ever National Park" }]
},
WA: { state: "Washington", parks: [] },
WY: { state: "Wyoming", parks: [{ name: "Cowboy Happy Land" }] }
};
app.get('/parks', (req, res, next) => {
res.render('parks', {parks: nationalParks});
});
const port = process.env.PORT || 8080;
app.listen(port, () => console.log(`Listening on port ${port}`));