Node.js express get

Description

Node.js express get

var express = require('express');
var app = express();

app.get('/', function (req, res) {
  res.setHeader('Content-Type', 'text/plain'); 
  res.end('Hello, world!');
});/*from  w ww. j av  a  2  s .c o  m*/

app.get('/:name', function(req, res){
  var name = req.params.name; 
  res.send('Hello, ' + name);
});


app.listen(1337);
console.log('Listening on port 1337');



PreviousNext

Related