|
有幸从http://nodejs.org下了一份nodejs, 现在有windows下的node.exe直接下载了,不用自己手动编译,省了很多时间。
简略的看了下它的库结构,
涉及到Console, Event, Socket, 文件IO, 加密
看来用它编写操作系统相关的类shell脚本应该不错,编写简单的TCP/IP服务器端应用,似乎也可以。代码非常简洁。
只要写一个简单的first.js:
var http = require('http');
http.createServer(function (request, response) {
response.writeHead(200, {'Content-Type': 'text/plain'});
response.end('Hello World\n');
}).listen(8124);
console.log('Server running at http://127.0.0.1:8124/');
然后在命令行下执行:
node first.js
就会显示:
E:\TDdownload\nodejs>node first.js
Server running at http://127.0.0.1:8124/
用浏览器打开http://127.0.0.1:8124/,就会出现上边的Hello World!
有人说,nodejs可能会超过python,perl等脚本语言在WebServer上的应用,让时间来证明吧。 |
|
|