35 lines
819 B
JavaScript
35 lines
819 B
JavaScript
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);
|
|
|