Thursday, January 16, 2014

This is basic sample with connect in NodeJS

User query, and logger given by connect Lib


/**
 * Created by David on 14. 1. 17.
 */
var connect  = require('connect');

var server = connect.createServer();

server.use(connect.logger());
server.use(connect.query());
server.use(function(request, response){
    response.writeHead(200, {'Content-Type' : 'text/html'});
    response.end('<h1>'+JSON.stringify(request.query)+'</h1>');
});

server.listen(8888, function(){
    console.log('8888 is running');
});

No comments:

Post a Comment