菜单 学习猿地 - LMONKEY

VIP

开通学习猿地VIP

尊享10项VIP特权 持续新增

知识通关挑战

打卡带练!告别无效练习

接私单赚外块

VIP优先接,累计金额超百万

学习猿地私房课免费学

大厂实战课仅对VIP开放

你的一对一导师

每月可免费咨询大牛30次

领取更多软件工程师实用特权

入驻
99
0

服务器端的JavaScript脚本 Node.js 使用入门

原创
05/13 14:22
阅读数 73865


第一个例子:hello world。


复制代码 代码如下:

var sys = require("sys");
sys.puts("Hello world");



第二个例子:hello world2。


复制代码 代码如下:

var sys = require("sys"),
http = require("http");
http.createServer(function(request, response) {
response.sendHeader(200, {"Content-Type": "text/html"});
response.write("Hello World!");
response.close();
}).listen(8080);
sys.puts("Server running at http://localhost:8080/");


第三个例子:hello world2。

复制代码 代码如下:

var Buffer = require('buffer').Buffer,
buf DMqAzaNEY编程客栈= new Buffer(256),
len = buf.write('\u00bd + \u00bc = \u00be', 0);
console.log(len + " bytes: " + buf.toString('utf8', 0, len));

第四个例子:hello world3。
复制代码 代码如下:

//synopsis.js
//synopsis 摘要, 梗概,大纲
var http = require('http');

http.createServer(f编程客栈unction (request, response) {
response.writeHead(200, {'Content-Type': 'text/plain'});
response.end('Hello World\n');
}).listen(8124);

console.log('Server running at http://127.DMqAzaNEY0.0.1:8124/');

编程客栈

第五个例子:编译C文件
复制代码 代码如下:

#include #include int main(){ printf("Hello World!!!"); exit(0); }
本文标题: 服务器端的JavaScript脚本 Node.js 使用入门
本文地址: http://www.cppcns.com/wangluo/javascript/130202.html

发表评论

0/200
99 点赞
0 评论
收藏
为你推荐 换一批