您的位置:首页 > Web前端 > Node.js

14.11.3【node.js】做一个最简单的helloworld程序

2014-11-03 12:37 471 查看
//调用http
var http = require('http');
http.createServer(function (req, res) {
//200是http状态码,比如404是服务器错误,200是正常运行
res.writeHead(200, { 'Content-Type': 'text/plain' });
res.end('Hello World\n');
//4000是端口名称 随便写一个数就行
}).listen(4000);
//cosole.log是C语言printf的意思,输出,console是控制台
console.log('Server running at port 4000');
//运行此程序在网页上输入 http://localhost:4000/[/code] 
                                            
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: