Note that there are some explanatory texts on larger screens.

plurals
  1. POMy http.createserver in node.js doesn't work?
    text
    copied!<p>Hello guys i just started learning node.js today and search a lot off stuff on the internet , then try to code in node.js i use these two codes to show me the same result but the last one is show the error on my browser something likes "can not find the page".So please explain to me why?</p> <pre><code>// JScript source code var http = require('http'); http.createServer(function (req, res) { res.writeHead(200, { 'Content-Type': 'text/plain' }); res.end('Hello World\n'); }).listen(1337, "127.0.0.1"); console.log('Server running at http://127.0.0.1:1337/'); </code></pre> <p>This is working but</p> <pre><code>// Include http module. var http = require("http"); // Create the server. Function passed as parameter is called on every request made. // request variable holds all request parameters // response variable allows you to do anything with response sent to the client. http.createServer(function (request, response) { // Attach listener on end event. // This event is called when client sent all data and is waiting for response. request.on("end", function () { // Write headers to the response. // 200 is HTTP status code (this one means success) // Second parameter holds header fields in object // We are sending plain text, so Content-Type should be text/plain response.writeHead(200, { 'Content-Type': 'text/plain' }); // Send data and end response. response.end('Hello HTTP!'); }); }).listen(1337, "127.0.0.1"); </code></pre> <p>This one is not working</p> <p>Why?</p> <p>The link of the last one that's not working <a href="http://net.tutsplus.com/tutorials/javascript-ajax/node-js-for-beginners/">http://net.tutsplus.com/tutorials/javascript-ajax/node-js-for-beginners/</a> Thank you for all the answers, but i still don't understand about the problems. the last one that is not working just has request.on?</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload