radio-parasite-front/index.js

35 lines
819 B
JavaScript
Raw Normal View History

2015-10-16 22:43:20 +11:00
var sqlite3 = require('sqlite3').verbose();
var db = new sqlite3.Database('/Users/pg/code/tb/mydb.sqlite');
var express = require('express');
var app = express();
app.set('views', './views')
app.set('view engine', 'jade')
app.use(express.static('assets'));
/*
app.get('/', function(req, res){
res.render('index', {})
});
*/
app.get('/json', function (req, res) {
console.log('and this matches too');
var emissions=[]
db.all("SELECT * FROM emissions", function(err, rows) {
res.send(rows)
})
});
app.get('/', function (req, res) {
console.log('and this matches too');
var emissions=[]
db.all("SELECT * FROM emissions", function(err, rows) {
res.render('index', {emissions:rows})
})
});
app.listen(3000);