-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.js
53 lines (43 loc) · 1.32 KB
/
app.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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
const express = require('express');
const app = express();
const path = require('path');
const port = 8080;
const fs = require('fs');
const bodyParser = require('body-parser');
var knex = require('knex')({
client: 'pg',
connection: {
host : 'jivedb.cc7cumgtmetx.us-west-1.rds.amazonaws.com',
user : 'Jive',
password : 'storeStuff7',
database : 'JiveDB'
},
acquireConnectionTimeout: 10000
});
app.use(express.static(__dirname + '/public'));
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({ extended: false }));;
app.get('/', (req, res) => {
console.log(Date.now());
res.sendFile(path.join(__dirname + "/public/index.html"));
}
);
//Submits email into email storage
app.post('/', function(req,res){
const emailObject = {
name: req.body.name,
email: req.body.email
};
knex.insert(emailObject).into('email_list').asCallback(function(err) {
if (err) {
console.log(err);
}
});
/*let newDate = month + "/" + day + "/" + year + " --- Hour: " + hour;
fs.appendFile('./emailList.txt', name + ' --- ' + email + ' --- ' + newDate + '\n', function (err) {
if (err) throw err;
console.log('Saved Email!');
});
res.sendFile(path.join(__dirname + "/public/afterSubmit.html"));*/
});
app.listen(port, () => console.log('About Us app listening on port ' + port));