1const express = require('express')
2const app = express()
3const port = 3000
4
5app.get('/', (req, res) => {
6 res.send('Hello World!')
7})
8
9app.listen(port, () => {
10 console.log(`Example app listening at http://localhost:${port}`)
11})
1res.redirect('/foo/bar')
2res.redirect('http://example.com')
3res.redirect(301, 'http://example.com')
4res.redirect('../login')
5
1app.get('/', (req, res) => {
2 req.header('User-Agent')
3})
4// Use the Request.header() method to access
5//one individual request header’s value
1Express.js, or simply Express, is a web application framework for Node.js,
2released as free and open-source software under the MIT License.
3
4It is designed for building web applications and APIs.
5It has been called the de facto standard server framework for Node.js.
1app.render('email', function (err, html) {
2 // ...
3})
4
5app.render('email', { name: 'Tobi' }, function (err, html) {
6 // ...
7})
8