压缩:
从index.html压缩成index.html.gz
const zlib = require('zlib');
const gzip = zlib.createGzip();
const fs = require('fs');
const inp = fs.createReadStream('index.html');
const out = fs.createWriteStream('index.html.gz');
inp.pipe(gzip)
.on('error', () => {
// 处理错误
})
.pipe(out)
.on('error', () => {
// 处理错误
});
解压:
从index.html.gz解压为index.html
const zlib = require('zlib');
const gzip = zlib.createGzip();
const fs = require('fs');
const inp = fs.createReadStream('index.html.gz');
const out = fs.createWriteStream('index.html');
inp.pipe(gzip)
.on('error', () => {
// 处理错误
})
.pipe(out)
.on('error', () => {
// 处理错误
});
node线上项目连接mysql出现 504 Gateway Time-Out
var connection = mysql.createConnection({
host : 'localhost',
user : 'root',
password : '123456',
port: '3306',
database: 'test'
});
一定别忘了加端口号 ↓
port: '3306',
。。。。。。。。。。。。。
作者:Vam的金豆之路
篇幅有限更多请见扩展链接:http://www.mark-to-win.com/tutorial/50820.html
留言与评论(共有 0 条评论) “” |