2014-01-22 4 views
1
내가 튜토리얼 ( http://debuggable.com/posts/understanding-node-js:4bd98440-45e4-4a9a-8ef7-0f7ecbdd56cb를) Node.js를이 초보자를 다음있어

을에/로딩 매달려 유지하고 난 그냥이 코드를 사용하여 내 첫 번째 서버를 만들었습니다,Node.js를 로컬 호스트

var http = require("http") 

http.createServer(

    function(request, response){ 

     response.writeHead(200, {"Content-Type":"text/plain"}) 
     response.write("hello world") 
     response.end 

    } 


).listen(3333) 

이 잘 작동을하지만 할 때 나는 localhost : url에 간다. 3333/나는 "hello world"라는 단어를 매우 간략하게 본 다음 단지 사라진다.

빠른 영상이 포도 나무를 참조하십시오 https://vine.co/v/MBJrpBEQvLX

어떤 아이디어?

답변

0

를 읽어 보는 것이 좋을 것.

코드를 읽어야합니다

var http = require("http"); 

http.createServer(function(request, response){ 
     response.writeHead(200, {"Content-Type":"text/plain"}); 
     response.write("hello world"); 
     response.end(); 
    }).listen(3333); 
+0

를 호출하는 것을 잊었다는 사실 때문이었다. .. – kevinius

+2

세미 콜론은 절대적으로 관련이 없습니다. 그는'response.end()'를 호출하지 않았다. 그것은 유일한 문제였다. Javascript는 거의 모든 경우에 세미콜론없이 완벽하게 유효합니다. –

1

Hello World를 response#end()에 입력하십시오. 나는 또한 당신은 response.end()의 끝 부분에 괄호를 넣어 잊어 NodeJS API

http.createServer(function (req, response) { 
    response.writeHead(200, {'Content-Type': 'text/plain'}); 
    response.end('Hello World\n'); 
}).listen(3333); 
+0

들으, 내가 API를 읽어 줄 테니, 당신 sollution는 일을하지만 내가, 들으을했다 .END 방법 – kevinius