-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.js
More file actions
46 lines (34 loc) · 935 Bytes
/
app.js
File metadata and controls
46 lines (34 loc) · 935 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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
/* git add .
git commit -m "msg"
git push -u origin main */
// git commit --amend -m "New message" - amend the last commit dropped
import express from 'express';
import seedPosts from './data/seedPosts.js';
const app = express();
const port = 4789;
app.use(express.urlencoded({extended: true}))
app.use(express.static('public'));
app.set('view engine', 'ejs');
app.get('/', (req, res) => {
res.render('home.ejs');
})
app.get('/view-article', (req, res) => {
const mockPosts = seedPosts;
res.render('view-article.ejs', {mockPosts});
})
app.get('/all-articles', (req, res) => {
res.render('all-articles.ejs');
})
app.get('/create', (req, res) => {
res.render('create.ejs');
})
// aux pages
app.get('/about', (req, res) => {
res.render('about.ejs');
})
app.get('/contact', (req, res) => {
res.render('contact.ejs');
})
app.listen(port, () => {
console.log('server running at port', port)
})