node.js入门实例helloworld详解
作者:bea
本文实例讲述了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'); //hel
本文实例讲述了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
提示服务启动(Server has started),然后在浏览器中输入http://localhost:2222/,即可以看到下图的效果。
执行成功后的效果
希望本文所述对大家node.js程序设计有所帮助。
有用 | 无用
将下面的代码保存为: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
提示服务启动(Server has started),然后在浏览器中输入http://localhost:2222/,即可以看到下图的效果。
执行成功后的效果
希望本文所述对大家node.js程序设计有所帮助。
有用 | 无用
猜你喜欢
您可能感兴趣的文章:
- jquery捕捉回车键及获取checkbox值与异步请求的方法
- jquery遍历函数siblings()用法实例
- jQuery中的siblings用法实例分析
- JQuery标签页效果实例详解
- 谈谈我对JavaScript原型和闭包系列理解(随手笔记9)
- JQuery实现Ajax加载图片的方法
- 谈谈我对JavaScript原型和闭包系列理解(随手笔记8)
- js中flexible.js实现淘宝弹性布局方案
- 正则表达式优化JSON字符串的技巧
- jQuery实现移动端滑块拖动选择数字效果
- 不得不分享的JavaScript常用方法函数集(上)
- JQuery实现的按钮倒计时效果
- 基于jquery实现鼠标左右拖动滑块滑动附源码下载
- JS实现的倒计时效果实例(2则实例)
- JavaScript对象数组排序函数及六个用法
- JavaScript中的函数(二)
- 分享JavaScript与Java中MD5使用两个例子
- js实现正则匹配中文标点符号的方法
- jquery实现点击其他区域时隐藏下拉div和遮罩层的方法