Add js reload timer to template; add timestamp to console GET message; temp disable email

This commit is contained in:
jkaplon 2015-07-03 21:38:40 -04:00
parent 1aadb08db0
commit eea9567b9b
2 changed files with 21 additions and 9 deletions

View File

@ -57,9 +57,10 @@ app.set('views', __dirname + '/views');
app.get('/', function(req, res){
//res.sendFile("/usr/src/app/index.html");
//fs.createReadStream('./log.log').pipe(res);
console.log("got a GET request...");
var d = new Date();
console.log("GET request at, " + JSON.stringify(d, 4));
db.all("SELECT coreId, published_at FROM Alerts ORDER BY published_at DESC LIMIT 30;", function(err, rows){
console.log(rows);
//console.log(rows);
res.render('home', {alerts: rows}, function(err, html) {
res.send(html);
});
@ -80,13 +81,16 @@ app.post('/', function(req, res){
JSON.stringify(req.body.published_at, null, 4)
);
stmt.finalize();
transporter.sendMail(mailOptions, function(error, info){
if(error){
console.log(error);
}else{
console.log('Message sent: ' + info.response);
}
});
// Emails were working...don't need to send on every POST anymore.
//transporter.sendMail(mailOptions, function(error, info){
//if(error){
//console.log(error);
//}else{
//console.log('Message sent: ' + info.response);
//}
//});
//res.send(JSON.stringify(req.body, null, 4));
});

View File

@ -10,5 +10,13 @@
<li>{{this.coreId}}: {{this.published_at}}</li>
{{/each}}
</ul>
<script>
setTimeout(
function() {
location.reload();
}, 5000
);
</script>
</body
</html>