-
-
Notifications
You must be signed in to change notification settings - Fork 43
Expand file tree
/
Copy pathapp.js
More file actions
26 lines (19 loc) · 672 Bytes
/
app.js
File metadata and controls
26 lines (19 loc) · 672 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
const express = require('express');
const path = require('path');
const app = express();
const port = 3000;
//Setting up template engine with pug
app.set('view engine', 'pug');
//Set the view directory
app.set('views', path.join(__dirname, 'views'));
//Using the template and serving it on the url
app.get('/hello', (req, res)=>{
res.status(200).render('hello', { title: 'Hey Kaiwalya', message: 'This is templated using pug template engine' })
});
app.use('/static', express.static('static'));
app.get('/', (req, res)=>{
res.send('Is this some kind of a joke?');
});
app.listen(port, ()=>{
console.log(`Server is live at http://127.0.0.1:${port}`);
});