-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.js
More file actions
31 lines (22 loc) · 765 Bytes
/
app.js
File metadata and controls
31 lines (22 loc) · 765 Bytes
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
var express = require('express');
var app = express();
var port = 5000;
var bookRouter = express.Router();
app.set("views", "./src/views/");
app.use(express.static('public'));
app.set('view engine', 'ejs');
bookRouter.route("/")
.get(function (req, res) {
res.render('books', { nav: [{ Link: '/Books', Text: 'Books' }, { Link: '/Authors', Text: 'Authors' }] });
});
bookRouter.route("/single")
.get(function (req, res) {
res.send("Hello Single Books");
});
app.use("/Books", bookRouter);
app.get('/', function (req, res) {
res.render('index', { nav: [{ Link: '/Books', Text: 'Books' }, { Link: '/Authors', Text: 'Authors' }] })
});
app.listen(port, function (err) {
console.log('running server on port ' + port);
});