手机
当前位置:查字典教程网 >编程开发 >Javascript教程 >node.js入门实例helloworld详解
node.js入门实例helloworld详解
摘要:本文实例讲述了node.js入门实例helloworld。分享给大家供大家参考,具体如下:将下面的代码保存为:server.js存到E盘下面...

本文实例讲述了node.js入门实例helloworld。分享给大家供大家参考,具体如下:

将下面的代码保存为:server.js存到E盘下面的node目录中。

var http = require('http'); function myNode(request, response){ response.writeHead(200, {'Content-type':'text/plain'}); response.write('hello world'); //hello world response.end(); } http.createServer(myNode).listen(2222); //监听2222端口 console.log('Server has started'); //在控制台提示服务启动

然后在windows命令行输入node e:/node/server.js

node.js入门实例helloworld详解1

提示服务启动(Server has started),然后在浏览器中输入http://localhost:2222/,即可以看到下图的效果。

node.js入门实例helloworld详解2

执行成功后的效果

希望本文所述对大家node.js程序设计有所帮助。

【node.js入门实例helloworld详解】相关文章:

js同源策略详解

JQuery中层次选择器用法实例详解

js的event详解。

javascript原型模式用法实例详解

Node.js 条形码识别程序构建思路详解

js事件监听器用法实例详解

制作特殊字的脚本

js中跨域方法原理详解

javascript瀑布流布局实现方法详解

JavaScript中this关键字使用方法详解

精品推荐
分类导航