Advantages of Express
Express is a web application framework for Node.js, modeled after the Ruby project Sinatra.[66] 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.
â | â'use strict'â; |
â | âconstâ http = require(â'http'â); |
â | âconstâ server = http.createServer((req, res) => { |
â | res.writeHead(200, {â'Content-Type'â: â'text/plain'â}); |
â | res.end(â'Hello Worldââ\âân'â); |
â | }); |
â | server.listen(60700, () => console.log(â'Ready!'â)); |
This is quite similar to creating a basic TCP server using the net module like you did way back in Chapter 3, âNetworking ...
Get Node.js 8 the Right Way now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.