Guest User

Untitled

a guest
Dec 14th, 2017
58
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.60 KB | None | 0 0
  1. gulp.task("server", ['build'], function () {
  2. $.util.log($.util.colors.green("Server started at http://localhost:" + 4000));
  3. server.listen(PORT);
  4.  
  5. open("http://localhost:" + PORT);
  6. });
  7.  
  8. server.get("*", function(req, res){
  9. var base = __dirname + "/dist";
  10. var path = base + decodeURIComponent(req.path);
  11. console.log(path);
  12. try{
  13. var stat = fs.lstatSync(path);
  14.  
  15. }
  16. catch(e){
  17. res.sendFile('index.html', { root: base });
  18. return;
  19. }
  20. if(stat.isFile())
  21. res.sendFile(path);
  22. else{
  23. res.sendFile('index.html', { root: base });
  24. }
  25. });
Add Comment
Please, Sign In to add comment