diff options
| author | Adam Soltys <[email protected]> | 2012-11-13 19:27:09 -0800 |
|---|---|---|
| committer | Adam Soltys <[email protected]> | 2012-11-13 19:27:09 -0800 |
| commit | 16062edf148ea44bc8a5f40732c0dc1d363d588c (patch) | |
| tree | 1c29230affc47ce26fee30d9f971c1f75e79a43a /app.coffee | |
| parent | 54c28a395db853c601d3592c967f322c7f09e1d4 (diff) | |
| download | coinos-server-16062edf148ea44bc8a5f40732c0dc1d363d588c.tar.gz coinos-server-16062edf148ea44bc8a5f40732c0dc1d363d588c.zip | |
Allow market selection
Diffstat (limited to 'app.coffee')
| -rw-r--r-- | app.coffee | 32 |
1 files changed, 22 insertions, 10 deletions
@@ -1,3 +1,4 @@ + express = require('express') http = require('http') path = require('path') @@ -54,13 +55,10 @@ app.get('/:user/transactions', (req, res) -> app.get('/ticker', (req, res) -> - symbol = req.params.symbol - symbol or= 'virtexCAD' - options = host: 'bitcoincharts.com', - path: '/t/depthcalc.json?symbol=' + symbol + '&type=bid&amount=1000¤cy=true' - + path: '/t/depthcalc.json?symbol=' + req.query.symbol + '&type=bid&amount=1000¤cy=true' + require('http').get(options, (r) -> r.setEncoding('utf-8') r.on('data', (chunk) -> @@ -70,11 +68,17 @@ app.get('/ticker', (req, res) -> ) app.post('/users', (req, res) -> - db = require("redis").createClient() - db.hmset(req.body.login, req.body, -> - res.writeHead(302, 'Location': '/' + req.body.login) - res.end() - ) + if req.body.login + db = require("redis").createClient() + db.hmset(req.body.login, req.body, -> + res.redirect(req.body.login) + ) + else + params = [] + for k,v of req.body + params.push(encodeURIComponent(k), '=', encodeURIComponent(v), '&') + params.pop() if (params.length) + res.redirect('calculator?' + params.join('')) ) app.post('/:user/transactions', (req, res) -> @@ -90,6 +94,13 @@ app.post('/:user/transactions', (req, res) -> ) ) +app.get('/calculator', (req, res) -> + res.render('calculator', + js: (-> global.js), + css: (-> global.css) + ) +) + app.get('/:user', (req, res) -> res.render('calculator', user: req.params.user, @@ -102,4 +113,5 @@ app.use((err, req, res, next) -> console.log(err) ) + app.listen(3000) |
