var http = require('http');
var fs = require('fs');
var url = require('url');
http.createServer( function (request, response) {
var pathname = url.parse(request.url).pathname;
console.log("Request for " + pathname + " received.");
response.writeHead(200, {'Content-Type': 'text/html'});
fs.readFile('./head.html',function(e,head){
fs.readFile(pathname.substr(1), function (err, data) {
fs.readFile('./foot.html',function(e,foot){
console.log(head.toString())
console.log(foot.toString())
response.write("<!DOCTYPE html>");
response.write("<html lang=\"en\">");
response.write("<head>");
response.write("<meta charset=\"UTF-8\">");
response.write("<title>標(biāo)題一</title>");
response.write("</head>");
response.write(data.toString());
response.write(foot.toString());
response.end();
})
});
})
}).listen(3000);
console.log('Server running at http://127.0.0.1:3000/');
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>標(biāo)題</title>
</head>
b. index.html:
創(chuàng)新互聯(lián)咨詢電話:18982081108,為您提供成都網(wǎng)站建設(shè)網(wǎng)頁(yè)設(shè)計(jì)及定制高端網(wǎng)站建設(shè)服務(wù),創(chuàng)新互聯(lián)網(wǎng)頁(yè)制作領(lǐng)域10余年,包括成都建筑動(dòng)畫等多個(gè)行業(yè)擁有豐富建站經(jīng)驗(yàn),選擇創(chuàng)新互聯(lián),為企業(yè)保駕護(hù)航!
<body>
<h2>身體</h2>
<p>這是一段文字</p>
</body>
c. foot.html:
<script>
</script>
</html>
當(dāng)前標(biāo)題:前后端分離用nodejs做seo
當(dāng)前鏈接:http://sd-ha.com/article42/iedphc.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供網(wǎng)站維護(hù)、品牌網(wǎng)站制作、、面包屑導(dǎo)航、搜索引擎優(yōu)化、響應(yīng)式網(wǎng)站
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來(lái)源: 創(chuàng)新互聯(lián)