diff options
| -rw-r--r-- | app.js | 52 | ||||
| -rw-r--r-- | package.json | 4 | ||||
| -rw-r--r-- | public/js/bitcoin_pos.js | 2 |
3 files changed, 31 insertions, 27 deletions
@@ -1,36 +1,38 @@ - -/** - * Module dependencies. - */ - var express = require('express') - , routes = require('./routes') - , user = require('./routes/user') , http = require('http') - , path = require('path'); + , path = require('path') + , engines = require('consolidate') + , app = express(); -var app = express(); +app.engine('html', engines.hogan); +app.set('view engine', 'html'); +app.set('views', __dirname + '/views'); +app.use(express.static(path.join(__dirname, 'public'))); -app.configure(function(){ - app.set('port', process.env.PORT || 3000); - app.set('views', __dirname + '/views'); - app.use(express.favicon()); - app.use(express.logger('dev')); - app.use(express.bodyParser()); - app.use(express.methodOverride()); - app.use(app.router); - app.use(express.static(path.join(__dirname, 'public'))); +app.get('/', function(req, res) { + res.render('index'); }); -app.configure('development', function(){ - app.use(express.errorHandler()); +app.get('/report', function(req, res) { + res.render('report'); }); -app.get('/users', user.list); -app.get('/:client', function() { - res.render('index', { title: req.param('client') }); +app.get('/ticker', function(req, res) { + var options = { + host: 'bitcoincharts.com', + path: '/t/depthcalc.json?symbol=virtexCAD&type=bid&amount=1001¤cy=true' + } + + require('http').get(options, function(r) { + r.setEncoding('utf-8'); + r.on('data', function(chunk) { + res.send(chunk); + }); + }); }); -http.createServer(app).listen(app.get('port'), function(){ - console.log("Express server listening on port " + app.get('port')); +app.get('/:client', function(req, res) { + res.render('calculator', { title: req.param('client') }); }); + +app.listen(3000); diff --git a/package.json b/package.json index fe9afd86..2230d4bb 100644 --- a/package.json +++ b/package.json @@ -6,6 +6,8 @@ "start": "node app" }, "dependencies": { - "express": "3.0.1" + "express": "3.0.1", + "consolidate": "0.5.0", + "hogan.js": "2.0.0" } } diff --git a/public/js/bitcoin_pos.js b/public/js/bitcoin_pos.js index 5d8f551b..82d5f879 100644 --- a/public/js/bitcoin_pos.js +++ b/public/js/bitcoin_pos.js @@ -53,7 +53,7 @@ $(function() { } function fetchExchangeRate() { - $.getJSON('ticker.php') + $.getJSON('ticker') .success(function (data) { if (data == null) { exchangeFail(); |
