January 2018
Intermediate to advanced
336 pages
7h 22m
English
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 with Sockets. We bring in the http module, call its createServer() ...
Read now
Unlock full access