November 2013
Intermediate to advanced
148 pages
3h 12m
English
Express is a web application framework for Node modeled after the Ruby project Sinatra.[30] Express provides a lot of the plumbing code that you’d otherwise end up writing yourself. To see why, let’s take a look at a basic Node.js server using only the http module.
| web-services/server.js | |
| | const |
| | http = require('http'), |
| | server = http.createServer(function(req, res) { |
| | res.writeHead(200, {'Content-Type': 'text/plain'}); |
| | res.end('Hello World\n'); |
| | }); |
| | server.listen(3000, function(){ |
| | console.log('ready captain!'); |
| | }); |
This is quite similar to creating a basic TCP server using the net module. First we bring in the http module, call its createServer() method with a callback, and finally use server.listen() ...
Read now
Unlock full access