前后端分离用nodejs做seo
- 服务器(nodejs):
a. 要点:
b. 完整代码: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(""); response.write(""); response.write(""); response.write(""); response.write("
标题一 "); response.write(""); response.write(data.toString()); response.write(foot.toString()); response.end(); }) }); }) }).listen(3000); console.log('Server running at http://127.0.0.1:3000/'); - 前端html:
a. head.html:标题 b. index.html:
创新互联咨询电话:18982081108,为您提供成都网站建设网页设计及定制高端网站建设服务,创新互联网页制作领域10余年,包括成都建筑动画等多个行业拥有丰富建站经验,选择创新互联,为企业保驾护航!
身体
这是一段文字
c. foot.html:
文章标题:前后端分离用nodejs做seo
标题网址:http://azwzsj.com/article/iedphc.html