diff options
| author | Jules Laplace <jules@okfoc.us> | 2015-09-24 13:52:25 -0400 |
|---|---|---|
| committer | Jules Laplace <jules@okfoc.us> | 2015-09-24 13:52:25 -0400 |
| commit | 456814755f8c2559f08b6d4d4635a5ea6bc495f0 (patch) | |
| tree | 569b559d7af4b481c19b58fe0c6aaeef19c9f6e6 /lib | |
| parent | b817d4472ca905a0d380cf686ffa62f62297574a (diff) | |
browser functionality all working
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/db/index.js | 2 | ||||
| -rw-r--r-- | lib/index.js | 17 |
2 files changed, 9 insertions, 10 deletions
diff --git a/lib/db/index.js b/lib/db/index.js index b7b1b06..81c3af2 100644 --- a/lib/db/index.js +++ b/lib/db/index.js @@ -23,7 +23,7 @@ db.getLatest = function () { } db.getRandom = function () { return Image.query(function(qb){ - qb.orderBy(knex.raw('RANDOM()')).limit(1) + qb.orderBy(knex.raw('RAND()')).limit(1) }).fetch() } diff --git a/lib/index.js b/lib/index.js index fd226e5..7a410d0 100644 --- a/lib/index.js +++ b/lib/index.js @@ -5,13 +5,8 @@ var http = require('http'); var https = require('https'); var bodyParser = require('body-parser') var cookieParser = require('cookie-parser') -var csurf = require('csurf') var path = require('path') -var multiparty = require('multiparty') var ejs = require('ejs') -var passport = require('passport') -var sessionstore = require('sessionstore') -var session = require('express-session') var multer = require('multer') var app, server @@ -32,11 +27,12 @@ site.init = function(){ app.use(express.query()) server = http.createServer(app).listen(5000, function () { - console.log('Bucky listening at http://5.k:%s', server.address().port) + console.log('LuCkYPLoP listening at http://5.k:%s', server.address().port) }) - app.get("/p/:id", function(req, res){}) - + app.get("/p/:id", function(req, res){ + res.sendFile("index.html", {root: './public'}) + }) app.get("/get/random", function(req, res){ db.getRandom().then(function(img){ res.json(img) @@ -48,8 +44,11 @@ site.init = function(){ }) }) app.get("/get/:id", function(req, res){ - db.getImage(id).then(function(img){ + db.getImage(req.params.id).then(function(img){ res.json(img) }) }) + app.post("/upload", function(req, res){ + res.sendStatus(200) + }) }
\ No newline at end of file |
