app.use
app.use(express.static('public'))
app.use(express.static('files'))
app.use
app.use(express.static('public'))
app.use(express.static('files'))
app.use
const path = require('path')
app.use('/static', express.static(path.join(__dirname, 'public')))
what is app.use() used for
//app.get will see only exact match ex.> "/book" here app.get will not allow /book/1, etc
//but app.use is different see below
//what is difference between app.use and app.all
//app.use takes only 1 callback while app.all takes multiple callbacks
//app.use will only see whether url starts with specified path But, app.all() will match the complete path
app.use( "/book" , middleware);
// will match /book
// will match /book/author
// will match /book/subject
app.all( "/book" , handler);
// will match /book
// won't match /book/author
// won't match /book/subject
app.all( "/book/*" , handler);
// won't match /book
// will match /book/author
// will match /book/subject
Copyright © 2021 Codeinu
Forgot your account's password or having trouble logging into your Account? Don't worry, we'll help you to get back your account. Enter your email address and we'll send you a recovery link to reset your password. If you are experiencing problems resetting your password contact us