Skip to content

Commit 06a74f7

Browse files
author
codingChewie
committed
POST Requests
1 parent 463a22d commit 06a74f7

File tree

3 files changed

+17
-3
lines changed

3 files changed

+17
-3
lines changed

app.js

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,7 @@ const app = express()
55

66
app.set('view engine', 'pug')
77

8-
app.get('/', (req, res) => {
9-
res.render('index')
10-
})
8+
app.get('/', (req, res) => res.render('index'))
119

1210
app.get('/cards', (req, res) => {
1311
eyes.inspect(res.locals, 'res.locals')
@@ -17,4 +15,12 @@ app.get('/cards', (req, res) => {
1715
})
1816
})
1917

18+
app.get('/hello', (req, res) => {
19+
res.render('hello')
20+
})
21+
22+
app.post('/hello', (req, res) => {
23+
res.render('hello')
24+
})
25+
2026
app.listen(3000, () => console.log('The app is running on port 3000'))

views/hello.pug

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
extends layout.pug
2+
3+
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
File renamed without changes.

0 commit comments

Comments
 (0)