手机
当前位置:查字典教程网 >编程开发 >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的event详解。

prototype class详解

js中跨域方法原理详解

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

javascript的 {} 语句块详解

javascript动态创建表格及添加数据实例详解

Javascript递归打印Document层次关系实例分析

javascript原型模式用法实例详解

Webpack 实现 AngularJS 的延迟加载

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

精品推荐
分类导航