node.js入门示例
2016-01-16 15:36
579 查看
1、控制台版 Hello World
编辑文件hello_world.js
执行:node hello_world.js
结果:
![](http://img.blog.csdn.net/20160116153331466?watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQv/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/Center)
2、网页版Hello world
编译文件 http_hello_world.js
编辑文件hello_world.js
var sys = require("util"); sys.puts("Hello world");
执行:node hello_world.js
结果:
2、网页版Hello world
编译文件 http_hello_world.js
var http = require('http'); http.createServer(function (req, res) { res.writeHead(200, {'Content-Type': 'text/plain'}); res.end('Hello World - Node.js Work. '); }).listen(5656, '127.0.0.1'); console.log('Server running at ' target='_blank'>http://127.0.0.1:5656/');[/code] 执行: node http_hello_world.js
结果:![]()
相关文章推荐
- Node.js_Dns模块
- nodeJs-autoMerge
- nodeJs-autoBulid
- Hadoop集群中引入新DataNode节点
- 用Visual Studio Code写Node.j
- Node.js_Path模块
- Drupal 中对Node页面的Ajax修改
- Node.js_OS模块
- Node.js_Get和Post
- Node.js如何处理健壮性
- LightOJ--1094-- Farthest Nodes in a Tree(树的直径裸题)
- LightOJ--1094-- Farthest Nodes in a Tree(树的直径裸题)
- Leetcode 237 Delete Node in a Linked List 链表
- Nodejs的Express完成安装指导
- hadoop 2.6 Node,DatanodeID,datanodeInfo,DatanodeDescriptor解析
- Node.js学习1_记一次 Node.js 应用内存暴涨分析
- Leetcode 19 - Remove Nth Node From End of List
- nodejs小记之handlebars视图与静态文件布置
- hadoop namenode 格式化问题
- NODE.JS的基本系统模块操作样例