-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathserver.js
31 lines (24 loc) · 855 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
// server.js
const express = require('express');
const bodyParser = require('body-parser');
const path = require('path');
const index = require('./routes/index');
const tasks = require('./routes/tasks');
const app = express();
let port = process.env.PORT || 3000
// Setup View Engine
app.set('views', path.join(__dirname + '/views'));
app.set('view engine', 'ejs'); //specifies which view engine we want to use
// Allows us to render html files
app.engine('html', require('ejs').renderFile);
// Set Static Folder
app.use(express.static(__dirname));
// Set our bodyParser
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({extended: false}));
// // Sets our Routes
app.use('/', index);
app.use('/api', tasks);
app.listen(port, function() {
console.log('We have successfully connected to port: ', port);
});