Herramientas de usuario

Herramientas del sitio


wiki2:nodejs:express

¡Esta es una revisión vieja del documento!


Express JS

Basic

Installing

  1. Create a packages.json: $ npm init
  2. Install Express and save it in packages: $ npm install express –save

Basic app

var express = require('express');

var app = express();

app.listen(3000, function() {
  console.log("server started on Port 3000");
})

Routes

Take the get to de home (using request and the response):

app.get('/', fucntion(req, res) {
  res.send('Hello world');
});

Special functions

use is important to put it before any request.

var logger = function (req, res, next){
  console.log('Logging');
  next();
}
app.use(logger);
wiki2/nodejs/express.1494437598.txt.gz · Última modificación: 2020/05/09 09:24 (editor externo)