const http = require("http");
const fs = require("fs");
var tpl1 = '<!DOCTYPE html><html><head><title>测试render</title></head><body>helloword<p>$data1</p>';
var tpl2 = '<p>$data2</p></body></html>';
var html = '';
var server = http.createServer((req, res)=>{
if(req.url!=="/favicon.ico"){
res.writeHead(200, {
'Content-Type' : 'text/html'
});
getDataOne((data1) => {
getDataTwo((data2) => {
res.end(tpl1.replace(/\$data1/g, data1) + tpl2.replace(/\$data2/g, data2));
})
});
}
}).listen(3000, '127.0.0.1');
function getDataOne(fn){
setTimeout(() => {
fn('11111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111');
}, 5000);
}
function getDataTwo(fn){
setTimeout(() => {
fn('22222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222');
}, 5000);
}
const http = require("http");
const fs = require("fs");
var server = http.createServer((req, res)=>{
if(req.url!=="/favicon.ico"){
res.writeHead(200, {
'Content-Type' : 'text/html',
'Transfer-Encoding' : 'chunked'
});
getDataOne((data1) => {
res.write('<!DOCTYPE html><html><head><title>测试render</title></head><body>helloword<p>$data1</p>'.replace(/\$data1/g, data1));
getDataTwo((data2) => {
res.end('<p>$data2</p></body></html>'.replace(/\$data2/g, data2));
})
});
}
}).listen(3000, '127.0.0.1');
function getDataOne(fn1){
setTimeout(() => {
fn1('1111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111');
}, 5000);
}
function getDataTwo(fn2){
setTimeout(() => {
fn2('22222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222');
}, 5000);
}
机械节能产品生产企业官网模板...
大气智能家居家具装修装饰类企业通用网站模板...
礼品公司网站模板
宽屏简约大气婚纱摄影影楼模板...
蓝白WAP手机综合医院类整站源码(独立后台)...苏ICP备2024110244号-2 苏公网安备32050702011978号 增值电信业务经营许可证编号:苏B2-20251499 | Copyright 2018 - 2025 源码网商城 (www.ymwmall.com) 版权所有