$ npm install express --save
// index.js
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 on port ${port}!`))
Than run $ node index.js
https://expressjs.com/en/starter/generator.html
Installing Express generator: $ npm install -g express-generator
Creating a new project: $ express myapp && cd myapp && npm install
https://expressjs.com/en/guide/routing.html
// Basic routing
app.get('/', function (req, res) {
res.send('Hello World!')
})
// Parameters
app.get('/users/:userId/books/:bookId', function (req, res) {
res.send(req.params)
})
// Route path: /users/:userId/books/:bookId
// Request URL: http://localhost:3000/users/34/books/8989
// req.params: { "userId": "34", "bookId": "8989" }