diff options
Diffstat (limited to 'lib/index.js')
| -rw-r--r-- | lib/index.js | 27 |
1 files changed, 16 insertions, 11 deletions
diff --git a/lib/index.js b/lib/index.js index a53dc34..ef1aa5c 100644 --- a/lib/index.js +++ b/lib/index.js @@ -21,7 +21,6 @@ var upload = require("./upload") var site = module.exports = {} site.init = function(){ app = express() - app.use('/p', express.static(path.join(__dirname, '../public'))) app.use(bodyParser.json()) app.use(bodyParser.urlencoded({ extended: false })) @@ -39,6 +38,11 @@ site.init = function(){ res.json(img) }) }) + app.get("/p/get/", function(req, res){ + db.getLatest().then(function(img){ + res.json(img) + }) + }) app.get("/p/get/latest", function(req, res){ db.getLatest().then(function(img){ res.json(img) @@ -55,15 +59,16 @@ site.init = function(){ }) }) app.post("/p/upload", multer_upload.single('image'), function(req, res){ - upload.put("image", req.file, { - unacceptable: function(err){ - res.json({ error: err }) - }, - success: function(url){ - db.createImage(url).then(function(image){ - res.json(image) - }) - } - }) + upload.put("image", req.file, { + unacceptable: function(err){ + res.json({ error: err }) + }, + success: function(url){ + db.createImage(url).then(function(image){ + res.json(image) + }) + } + }) }) + app.use('/p/', express.static(path.join(__dirname, '../public'))) } |
