静态服务器

 静态服务器
      后端语言 + 后端渲染模板  生成前端的html结构,然后在发送到前台 ,这种做法就叫做后端渲染

  案例: Node + html/ejs/pug  ---> html结构 --》 前台

······const express = require( 'express' )
       const app = express()
       const PORT = 8000
      const HOST = 'localhost'
      const fs = require( 'fs' )
      app.get('/home',( request,response,next ) => {
     fs.readFile
    //static/htiml/index.html 这是一个路径
     fs.readFile( './static/html/index.html', 'utf8', ( error,docs ) => {
 
    if( error ){
      console.log( error )
    }else{
      response.send( docs )
    }
  })  

})

   app.listen( PORT,HOST,() => {
  console.log( `服务器运行在: http://${ HOST }:${ PORT }` )
})

posted @ 2019-07-19 10:56  everjin  阅读(170)  评论(0编辑  收藏  举报