Skip to content

Commit 774d778

Browse files
author
codingChewie
committed
The Response Object
1 parent e6f5acf commit 774d778

File tree

2 files changed

+10
-7
lines changed

2 files changed

+10
-7
lines changed

app.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,9 @@ app.get('/hello', (req, res) => {
2222
})
2323

2424
app.post('/hello', (req, res) => {
25-
console.log(req.body)
26-
res.render('hello')
25+
res.render('hello', {
26+
name: req.body.username,
27+
})
2728
})
2829

2930
app.listen(3000, () => console.log('The app is running on port 3000'))

views/hello.pug

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
extends layout.pug
22

33
block content
4-
h2 welcome, student
5-
form(action='/hello', method='POST')
6-
label Please enter name
7-
input(type='text', name='useranme')
8-
button(type='submit') Submit
4+
if name
5+
h2 welcome, #{name}
6+
else
7+
form(action='/hello', method='POST')
8+
label Please enter name
9+
input(type='text', name='username')
10+
button(type='submit') Submit

0 commit comments

Comments
 (0)