-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathserver.js
executable file
·31 lines (25 loc) · 937 Bytes
/
server.js
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
const express = require('express');
const logger = require('morgan');
const bodyParser = require('body-parser');
const methodOverride = require('method-override');
const path = require('path');
const responseController = require('./controllers/responseController');
const responseRouter = require('./router/responseRouter');
const app = express();
const PORT = process.env.PORT || 3000;
app.use(logger('dev'));
app.set('view engine', 'ejs');
app.use(bodyParser.urlencoded({ extended: false }));
app.use(methodOverride('_method'));
app.use(express.static(path.join(__dirname, 'public')));
app.get('/', responseController.index, (req, res) => {
res.render('index');
});
app.use('/responses', responseRouter);
app.use('*', (req, res) => {
res.render('404');
});
// Invoke app's .listen() method
app.listen(PORT, () => {
console.log(`Listening on port: ${PORT}`);
});