码迷,mamicode.com
首页 > Web开发 > 详细

nodejs http2https hbs

时间:2018-03-16 14:00:06      阅读:218      评论:0      收藏:0      [点我收藏+]

标签:page   write   min   replace   ror   ace   asc   mis   new   

const oUrl = require("url");

//
get 请求外网 function loadPage(url) { var http = require(‘http‘); var pm = new Promise(function (resolve, reject) { http.get(url, function (res) { var html = ‘‘; res.on(‘data‘, function (d) { html += d.toString() }); res.on(‘end‘, function () { resolve(html); }); }).on(‘error‘, function (e) { reject(e) }); }); return pm; }
hbs.registerHelper(‘http2https‘, function(url){
	var sUrl = ‘/http2https/s?=‘+url;
	return sUrl;
});

router.get(‘/http2https/*‘,function(req,res,next){ var url = req.originalUrl.replace(‘/http2https/s?=‘,‘‘); loadPage(url).then(function(d) { res.write(d); res.end(); }); });

 页面调用 <script src="{{http2https ‘http://min.static.xxx.com/min/?f=static/site/asset/script/xxx/common-min.js‘}}"></script>

nodejs http2https hbs

标签:page   write   min   replace   ror   ace   asc   mis   new   

原文地址:https://www.cnblogs.com/limingziqiang/p/8580657.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!