diff options
| author | Jules Laplace <julescarbon@gmail.com> | 2017-12-26 09:46:55 +0100 |
|---|---|---|
| committer | Jules Laplace <julescarbon@gmail.com> | 2017-12-26 09:46:55 +0100 |
| commit | 0ef7a5e0dc1a156a20ca75c8d75f0a26e814b02d (patch) | |
| tree | bffc7969e44daa916c3751ff7429a3a860f06c4c /lib/index.js | |
| parent | fc37dac763fcc9011121cfad2e91493521ebd0dc (diff) | |
scrubbing design
Diffstat (limited to 'lib/index.js')
| -rw-r--r-- | lib/index.js | 18 |
1 files changed, 8 insertions, 10 deletions
diff --git a/lib/index.js b/lib/index.js index 11c8a11..a53dc34 100644 --- a/lib/index.js +++ b/lib/index.js @@ -21,42 +21,40 @@ var upload = require("./upload") var site = module.exports = {} site.init = function(){ app = express() - app.set('view engine', 'ejs') - app.set('views', path.join(__dirname, '../views')) - app.use(express.static(path.join(__dirname, '../public'))) + app.use('/p', express.static(path.join(__dirname, '../public'))) app.use(bodyParser.json()) app.use(bodyParser.urlencoded({ extended: false })) - + app.use(express.query()) server = http.createServer(app).listen(process.env.PORT, function () { - console.log('LuCkYPLoP listening at http://5.k:%s', server.address().port) + console.log('plop listening at http://5.k:%s', server.address().port) }) app.get("/p/:id", function(req, res){ res.sendFile("index.html", {root: './public'}) }) - app.get("/get/random", function(req, res){ + app.get("/p/get/random", function(req, res){ db.getRandom().then(function(img){ res.json(img) }) }) - app.get("/get/latest", function(req, res){ + app.get("/p/get/latest", function(req, res){ db.getLatest().then(function(img){ res.json(img) }) }) - app.get("/get/:id/hotlink", function(req, res){ + app.get("/p/get/:id/hotlink", function(req, res){ db.getImage(req.params.id).then(function(img){ res.redirect(img.url) }) }) - app.get("/get/:id", function(req, res){ + app.get("/p/get/:id", function(req, res){ db.getImage(req.params.id).then(function(img){ res.json(img) }) }) - app.post("/upload", multer_upload.single('image'), function(req, res){ + app.post("/p/upload", multer_upload.single('image'), function(req, res){ upload.put("image", req.file, { unacceptable: function(err){ res.json({ error: err }) |
