// Send the HTTP header // HTTP Status: 200 : OK // Content Type: text/plain res.writeHead(200, {'Content-Type': 'text/plain'}); // Send the res body as "Hello World" res.end('Hello World\n'); }).listen(3000);
// Console will print the message console.log('Server running at http://127.0.0.1:3000/');
Node + Express
index.js file
1 2 3 4 5 6 7 8 9 10
let express = require("express"); let app = express();
app.get("/", function (req, res) { res.send("hello world"); });
app.listen(3000, function () { console.log("Server Started"); });