const http = require('http'); const server = http.createServer((req, res) => { res.end("This sets up a http server in Node.js. The http module is built-in in Node.js, we only have to require it (import in ES6). Now, just enter the following (I use Windows Subsystem for Linux - WSL in this case) in your shell to export NODE_DEBUG environment variable: export NODE_DEBUG=http We can now see requests and responses in our Node.js server! (Image below uses Wsl-Terminal as our terminal against WSL).Why hello world!
\n"); }); server.listen(4242, () => { console.log("Server is running..."); });
Friday, 28 December 2018
Debugging http Node.js server requests and responses from shell
Here is a cool tip to inspect Node.js running an http process / server.
First off, we start a simple http server in Node.js like this:
Java2D Code Examples to beginners and students
ReplyDeleteSuch a creative and informative blog!
ReplyDeleteSimple Game Ideas for Unity Unity Game Ideas are the things which are always in demand because to play games there is no age limit, every age people can play and enjoy it fully. Contact us now