To be or not to be.That is a question!

---源于莎士比亚的《哈姆雷特》

导航

随笔分类 -  nodejs

nodejs 文件上传
摘要:var multipart = require('connect-multiparty');var fs = require('fs');var multipartMiddleware = multipart();router.get('/uploadTest', function (req, re... 阅读全文

posted @ 2014-08-17 10:22 Ijavascript 阅读(385) 评论(0) 推荐(0)

Getting Started with Mongoose and Node.js – A Sample Comments System | Dev Notes
摘要:In this post, we’re going to be creating a sample comments system using Node, Express and Mongoose.Mongoose provides an object oriented interface for using MongoDB in Node.Everything in Mongoose starts with a Schema. Each schema maps to a MongoDB collection and defines the shape of the documents wit 阅读全文

posted @ 2014-02-14 15:33 Ijavascript 阅读(313) 评论(0) 推荐(0)

node io.sockt 聊天应用
摘要:index.html app.jsvar app=require('http').createServer(handler), io=require('socket.io').listen(app), fs=require('fs'); app.listen(8080); function handler(req,res){ fs.readFile(__dirname+'/index.html',function(err,data){ if (err) { res.writeHead(500... 阅读全文

posted @ 2013-10-17 15:07 Ijavascript 阅读(312) 评论(0) 推荐(0)

exploring the http Object
摘要:form.html server.jsvar http=require("http");var querystring=require("querystring");var util=require("util");var form=require("fs").readFileSync("form.html");http.createServer(function(request,response){ if (request.method==="POST") { var po 阅读全文

posted @ 2013-09-03 10:54 Ijavascript 阅读(265) 评论(0) 推荐(0)

node解析查询字符串
摘要:var http=require("http");var url=require("url");var pages=[ {id:"1",route:"",output:"Woohoo!"}, {id:"2",route:"about",output:"A simple routing width node example"}, {id:"3",route:"another page",output 阅读全文

posted @ 2013-07-24 10:48 Ijavascript 阅读(582) 评论(0) 推荐(0)

node事件发射器
摘要:demo:var events=require('events');var emitter=new events.EventEmitter();emitter.on('someEvent',function(arg1,arg2){ console.log('listener1',arg1,arg2);})emitter.on('someEvent',function(arg1,arg2){ console.log('listener2',arg1,arg2);})emitter.emit('someEven 阅读全文

posted @ 2013-06-02 10:17 Ijavascript 阅读(161) 评论(0) 推荐(0)

创建nodejs服务器
摘要:demo:var http=require('http');http.createServer(function(req,res){ res.writeHead(200,{'Conten-Type':'text/plain'}); res.end('Hello world\n');}).listen(1337,'127.0.0.1');console.log('Server running at http://127.0.0.1:1337'); 阅读全文

posted @ 2013-06-01 10:15 Ijavascript 阅读(133) 评论(0) 推荐(0)

在nodejs中如何用异步的方式读取一个文件
摘要:demo:var fs=require('fs');fs.readFile('file.txt', 'utf-8',function(err,data){ if(err){ console.error(err) } else { console.log(data); }});console.log('end'); 阅读全文

posted @ 2013-06-01 09:40 Ijavascript 阅读(199) 评论(0) 推荐(0)