var http = require("http");
function onRequest(request, response) {
console.log("函数开始执行");
response.writeHead(200, {"Content-type":"text/plain"});
response.wirte("hello");
response.end();
}
http.createServer(onRequest).listen(8888);
console.log("Server has startsed")
先获取node的http模块。
var http = require("http");
编写处理函数。onRequest
创建服务器并监听端口8888
http.createServer(onRequest).listen(8888);