-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathart.js
32 lines (23 loc) · 798 Bytes
/
art.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
var express = require('express');
var router = express.Router();
var fs = require('fs'),
request = require('request'),
apiKey = 'acc_6f7a484b37f02b2',
apiSecret = 'ef5124b7bcf7536392a623a2a3be4b1e',
filePath = './public/image.jpg';
/* GET home page. */
router.get('/', function(req, res, next) {
res.render('art', { title: 'App' });
});
router.post('/send', function(req,res,next) {
console.log(req.body);
var formData = {
image: fs.createReadStream(filePath)
};
request.post({url:'https://api.imagga.com/v2/tags', formData: formData},
function (error, response, body) {
console.log('Response:', body);
res.render('art', {info:body})
}).auth(apiKey, apiSecret, true);
})
module.exports = router;