12345678910111213141516171819202122232425262728 |
- const express = require('express');
- const http = require('http');
- const index = require('./routes/index.js');
- const livereload = require('livereload');
- const connectLivereload = require('connect-livereload')
- const path = require("path");
- const port = 3001;
- const viewsSrc = path.join(__dirname, 'views');
- const appLiveReload = livereload.createServer();
- appLiveReload.watch(viewsSrc)
- appLiveReload.server.once("connection", () => {
- setTimeout(() => {
- appLiveReload.refresh('/');
- }, 100);
- })
- const app = express();
- app.use(connectLivereload());
- app.use(express.static(path.join(__dirname, 'public')));
- app.set('views', viewsSrc);
- app.set('view engine', 'pug');
- app.get('/', index.index);
- http.createServer(app).listen(port, function(){
- console.log('Express server listening on port ' + port);
- });
|