Menu BAR

FEEL FREE TO ASK ANY PROGRAM and please mention any error if you find it

21 Dec 2023

Node js program to write HELLO WORLD

 // node js code to create a server and write HELLO WORLD!

var http = require ('http');

http.createServer (function (req,res) => {
res.writeHead(200, {'Content-Type': 'text/html'});
res.end('HELLO WORLD!');})
.listen(8080);


// Copy and paste the above code into a file and name it helloworld.js
// Now to run it, open the command prompt and go to the file location
// Execute the first command - >
//                                                 npm i http
//Execute the second command ->
//                                                node helloworld.js
// now open browser and copy and paste the link in the URL - http://localhost:8080

No comments:

Post a Comment