-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.js
34 lines (25 loc) · 845 Bytes
/
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
const express = require('express')
const app = express()
const port = 3000
const server = app.listen(7000, () => {
console.log(`Express running → PORT ${server.address().port}`);
});
//app.get('/', (req, res) => res.send('Hello World!'))
//app.get('/', (req, res) => res.render('index', {title: 'Home'}));
app.listen(port, () => console.log(`Example app listening on port ${port}!`))
app.set('view engine', 'pug');
app.use(express.static(__dirname + '/public'));
const people = require('./people.json');
app.get('/', (req, res) => {
res.render('index', {
title: 'Homepage',
people: people.profiles
});
});
app.get('/profile', (req, res) => {
const person = people.profiles.find(p => p.id === req.query.id);
res.render('profile', {
title: `About ${person.firstname} ${person.lastname}`,
person,
});
});