app.post('/api/imgurl', function(req, res){
unirest.post("https://camfind.p.mashape.com/image_requests")
.header("X-Mashape-Key", process.env.CAMFIND_KEY)
.header("Content-Type", "application/x-www-form-urlencoded")
.header("Accept", "application/json")
.send({
"image_request[locale]": req.body.locale,
"image_request[remote_image_url]": req.body.imgurl
})
.end(function (result) {
getReq(result.body.token, req.body.imgurl, function(resultBody, imgURL){
blackBox(resultBody, imgURL, function(classification){
res.send(200, {classification: classification, description: resultBody});
});
});
});
});
app.listen(process.env.PORT || 8080);