nodeJS 之 hello world!

var http = require('http');
function onRequest(resquest, response){
        response.writeHeader(200, "Conten-Type":"text/html");
        response.write('hello world');
	response.end();
}
http.createServer(onRequest).listen(8080);

下载nodesJS,windows下执行cmd,进入helloworld.js所在目录,执行node helloworld.js。

则服务器已经启动,浏览器访问localhost:8080,即可在浏览器上显示hello world;



你可能感兴趣的:(nodeJS 之 hello world!)