adspace


How to create a simple server in node js that returns hello world?

Answer Posted / Himanshu Singh

To create a simple server in Node.js that returns 'Hello World', you can use the http module. Here's an example: `const http = require('http'); const server = http.createServer((req, res) => { res.writeHead(200, {'Content-Type': 'text/plain'}); res.end('Hello Worldn') }); server.listen(3000, () => console.log('Server running at http://localhost:3000/'));

Is This Answer Correct ?    0 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Is node js losing popularity?

590


How we can read a file in node js?

571