欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

nodejs的helloworld

程序员文章站 2022-03-04 20:43:04
...
http://www.nodebeginner.org/index-zh-cn.html
这个不错
在windows下就可以运行
http://nodejs.org/
目前稳定版0.6.13
建个helloworld.js

console.log("Hello World");

node helloworld.js运行
如果跑http请求

console.log("Hello World");
var http = require("http");

http.createServer(function(request, response) {
response.writeHead(200, {"Content-Type": "text/plain"});
response.write("Hello World");
response.end();
}).listen(8888);

node helloworld.js
后,在http://localhost:8888/
可以看到效果

console.log("Hello World");
//-------------
var http = require("http");

http.createServer(function(request, response) {
response.writeHead(200, {"Content-Type": "text/plain"});
response.write("Hello World");
response.end();
}).listen(8888);
//-------------
function say(word) {
console.log(word);
}

function execute(someFunction, value) {
someFunction(value);
}

execute(say, "Hello");
//---------
function execute(someFunction, value) {
someFunction(value);
}

execute(function(word){ console.log(word) }, "Hello");


//var http = require("http");
//
//function onRequest(request, response) {
// response.writeHead(200, {"Content-Type": "text/plain"});
// response.write("Hello World");
// response.end();
//}
//
//http.createServer(onRequest).listen(8888);
相关标签: nodejs