May 2017
Beginner to intermediate
328 pages
7h 17m
English
Since we will use some WebGIS a bit later, let's make a web Hello world too. For this, a new project should be created using npm. Once ready, we will need an additional HTTP module to create a web server. This is a default Node.js module, so we just need to require it in our code:
const http = require('http'); const server = http.createServer((req, res) => { console.warn('Processing request...'); res.end('Hello world!'); }); const port = 8080; server.listen(port, () => { console.warn('Server listening on http://localhost:%s', port); });
In the preceding code, we bring in the HTTP module via a require method and assign it to a variable. Next, a server is created - whenever it receives a request it logs a message ...
Read now
Unlock full access