I am trying node.js as a possible technology as oppose to traditional php server for my school project, I am trying to initiate a server that prints hello, but for some reason my localhost won't display that, it only waits for localhost for a long time. Any help would be appreciated
var http = require("http");
http.createServer(function (request, response) {
request.on("end", function () {
response.writeHead(200, {
'Content-Type': 'text/plain'
});
response.end('Hello HTTP!');
});
}).listen(8080);
You don't need the request.on("end"):
http.createServer(function (request, response) {
response.writeHead(200, {
'Content-Type': 'text/plain'
});
response.end('Hello HTTP!');
}).listen(8080);