why node js code example
Example 1: what is node
npm install http then write a webserver...
const http = require('http');
const PORT = 3000;
const server = http.createServer((req, res) => {
res.statusCode = 200;
res.setHeader('Content-Type', 'text/plain');
res.end('Hello World');
});
server.listen(port, () => {
console.log(`Server running at PORT:${port}/`);
});
Example 2: node.js
When you install Node.js, you can do these things:
Make web servers
Run JavaScript without an HTML file
...and more!