How to create a simple server in node js that returns hello world?
Answer / 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 |
What are JavaScript task runners?
What template engines you can use with express?
How to generate unique uuids/ guid in node js?
Explain “Console” in Node.JS?
Why is js single threaded?
What is a Callback function in Node.js?
What is environment variable in node js?
What are the streams in node.js?
Why is yarn better than npm?
Write a simple code to enable cors in node js?
What are the functionalities of npm in node.js?
How node.js and javascript are related?