随笔分类 -  node.js风云

摘要:express框架初步使用 var exp = require('express'); var ejs = require('ejs'); var app = new exp(); app.set("view engine","ejs"); app.get('/index',function (re 阅读全文
posted @ 2019-11-25 00:29 saintdingtheGreat 阅读(192) 评论(0) 推荐(0)
摘要:伪对象形式 app = function () { console.log("我是一个初始化的app对象"); }; app.get=function () { console.log('这是一个app的get方法'); }; app.post = function () { console.log 阅读全文
posted @ 2019-11-22 22:02 saintdingtheGreat 阅读(313) 评论(0) 推荐(0)
摘要:一.开启一文件,这里暂且命名为aexpressclass.js 声明一个app类,用来模仿http模块中的回调函数 //var route = require('http-route'); var url = require('url'); //var app = new route(); var 阅读全文
posted @ 2019-11-17 02:36 saintdingtheGreat 阅读(382) 评论(0) 推荐(0)
摘要:事件广播 发送方调用emit方法,接收方调用on方法,无论发送方或是接收方,都会工作在一个频道 接收方 回调函数 阅读全文
posted @ 2019-10-25 12:44 saintdingtheGreat 阅读(424) 评论(0) 推荐(0)
摘要:有时候我们在windows上会保存一些中文文字信息文件,然而由于编码集的差异,这文件在linux上显示为乱码,其中一种解决方法是node.js的iconv模块 模块输出语句module.exports 引用时,必须声明一个变量接收引入的模块 阅读全文
posted @ 2019-10-25 00:16 saintdingtheGreat 阅读(860) 评论(0) 推荐(0)
摘要:链式反应--next() 上机结果: 阅读全文
posted @ 2019-09-04 14:05 saintdingtheGreat 阅读(187) 评论(0) 推荐(0)
摘要:fs.stat会返回文件夹会文件的属性 阅读全文
posted @ 2019-08-30 01:24 saintdingtheGreat 阅读(581) 评论(0) 推荐(0)
摘要:html文件代码 通过buffer流读取html文件 新建一个文件调取buffer读取定义好的函数 输出结果: 创建server返回结果 输出结果 阅读全文
posted @ 2019-08-28 17:42 saintdingtheGreat 阅读(1759) 评论(0) 推荐(0)
摘要:node.js没有二进制数据类型,却提供了类似字节数组的“流“数据类型,着一种数据类型在文件系统模块中频频出现 node.js打开文件 把文件内容读入缓冲区,并把缓冲区内容解读为utf8模式,(16进制也可以哦) 输出结果: 异步读取(data仍为缓冲区) 输出结果: 阅读全文
posted @ 2019-08-25 17:15 saintdingtheGreat 阅读(261) 评论(0) 推荐(0)
摘要:前端代码 效果: 点击提交以后,后端js脚本能够解析get和post请求参数和数据 node.js后端代const http = require('http');var myquerystring = require('querystring');var myurl = require('url') 阅读全文
posted @ 2019-06-14 23:42 saintdingtheGreat 阅读(867) 评论(0) 推荐(0)
摘要:httpserver fs模块 阅读全文
posted @ 2019-06-14 16:17 saintdingtheGreat 阅读(185) 评论(0) 推荐(0)