Send a response from a function to route in expressjs code example
Example 1: express hello world
const express = require('express')
const app = express()
const port = 3000
app.get('/', (req, res) => res.send('Hello World!'))
app.listen(port, () => console.log(`Example app listening at http://localhost:${port}`))
Example 2: widlicard in express router
app.get('/ab?cd', function (req, res) {
res.send('ab?cd')
})
app.get('/ab+cd', function (req, res) {
res.send('ab+cd')
})
app.get('/ab*cd', function (req, res) {
res.send('ab*cd')
})
app.get('/ab(cd)?e', function (req, res) {
res.send('ab(cd)?e')
})
app.get(/a/, function (req, res) {
res.send('/a/')
})
app.get(/.*fly$/, function (req, res) {
res.send('/.*fly$/')
})