1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33
| npm i gulp-webserver -D 装webserver
var webwerver =require('gulp-webserver'); gulp.task('webserver',function(){ gulp.src('./') .pipe(webwerver({ host:'localhost' ,port:80 ,directoryListing:{ enable:true, path:'./' } ,livereload:true middelware:function(req,res,next){ var urlOjb = url.parse(req.url,true) switch(urlOjb.pathname){ case '/api/orders': res.setHeader('Content-Type'.'application/json'); fs.readFile('./mock/list.json',function(err,data){ res.end(data); }) reruen; case 'api/uses': reruen;
} next(); } })) })
|