摘要: const http = require("http");const express = require("express");const mysql = require("mysql"); var pool = mysql.createPool({ host:'127.0.0.1', user:' 阅读全文
posted @ 2017-08-10 17:20 ThisCall 阅读(203) 评论(0) 推荐(0) 编辑
摘要: //处理客户post请求//*1:加载相应模块 http express querystring//*2:创建web服务器//*3:监听端口8080const http = require("http");const express = require("express");const qs = r 阅读全文
posted @ 2017-08-10 17:05 ThisCall 阅读(336) 评论(0) 推荐(0) 编辑
摘要: //1:加载相关模块 http express mysqlconst http = require("http");const mysql = require("mysql");const express = require("express");console.log(1);//2:创建连接池va 阅读全文
posted @ 2017-08-10 16:24 ThisCall 阅读(221) 评论(0) 推荐(0) 编辑
摘要: //1:加载http express框架//2:创建服务器const http = require("http");const express = require("express");var app = express();var server = http.createServer(app);s 阅读全文
posted @ 2017-08-10 15:52 ThisCall 阅读(1373) 评论(0) 推荐(0) 编辑
摘要: const http = require("http");const express = require("express");//3:创建express应用//4:创建服务器var app = express();//Express本质是一个处理请求函数var server = http.crea 阅读全文
posted @ 2017-08-10 15:27 ThisCall 阅读(273) 评论(0) 推荐(0) 编辑
摘要: //1:加载相应的模块 http url fs mysqlconst http = require("http");const url = require("url");const fs = require("fs");const mysql = require("mysql");//2:创建连接池 阅读全文
posted @ 2017-08-10 14:36 ThisCall 阅读(1889) 评论(0) 推荐(0) 编辑
摘要: const mysql = require("mysql");var conn = mysql.createConnection({ host:"127.0.0.1", user:'root', password:'', database:'jd', port:3306});//2:发送sql//c 阅读全文
posted @ 2017-08-10 13:06 ThisCall 阅读(149) 评论(0) 推荐(0) 编辑
摘要: //#使用nodejs编写动态的web服务器//1:加载需要模块 fs http urlconst fs = require("fs");const http = require("http");const url = require("url"); //2:创建web服务器//3:绑定端口var 阅读全文
posted @ 2017-08-10 11:59 ThisCall 阅读(406) 评论(0) 推荐(0) 编辑
摘要: //功能:创建web服务器接收客户请求// http://127.0.0.1:8080/index 准备// http://127.0.0.1:8080/news 准备// public/index.html// public/news.html// public/404.html//1:加载htt 阅读全文
posted @ 2017-08-10 09:58 ThisCall 阅读(1637) 评论(0) 推荐(0) 编辑
摘要: //1:加载http模块 httpconst http = require("http");//2:创建http 服务器var server = http.createServer();//3:为服务器绑定监听端口 8080//端品有效范围: 1023 65535server.listen(8080 阅读全文
posted @ 2017-08-10 09:49 ThisCall 阅读(197) 评论(0) 推荐(0) 编辑
摘要: console.log("1:开始读成取文件内容...");fs.readFile('./public/2.log',function(err,data){ if(err){ console.log("文件读取出现错误"); //console.log(err);错误的话返回code:ENOENT 阅读全文
posted @ 2017-08-10 09:17 ThisCall 阅读(267) 评论(0) 推荐(0) 编辑
摘要: //1:字节 byte//1024b = 1kb [千字节]//1024kb = 1mb [兆字节]//1024mb = 1gb [吉字节]//1024gb = 1tb [梯]//1024tb = 1pb //1:创建大小为1024字节缓冲区var buf1 = Buffer.alloc(1024) 阅读全文
posted @ 2017-08-10 09:02 ThisCall 阅读(194) 评论(0) 推荐(0) 编辑
摘要: const url = require("url");var u = "https://www.jd.com:443/ad/index?uname=qd";//将url解析js对象var obj = url.parse(u);console.log(obj);//true:指定querystring 阅读全文
posted @ 2017-08-10 08:16 ThisCall 阅读(113) 评论(0) 推荐(0) 编辑
摘要: const qs =require('querystring'); var str="uname=tom&upwd=123&pno=33&kw=js;" //查询字符串转成对象 var obj=qs.parse(str); console.log(obj) // 输出JS对象{uname:'tom' 阅读全文
posted @ 2017-08-10 08:14 ThisCall 阅读(117) 评论(0) 推荐(0) 编辑
摘要: JS文件中const fs = require("fs");console.log("开始进入文件读取..");//同步的写入var data = fs.readFileSync("./public/1.html"); console.log("文件读取完成");console.log(data); 阅读全文
posted @ 2017-08-10 07:08 ThisCall 阅读(7013) 评论(0) 推荐(0) 编辑