Skip to content

Commit

Permalink
Begin setting up API endpoints
Browse files Browse the repository at this point in the history
  • Loading branch information
Leta Keane committed May 25, 2017
1 parent 9c9b702 commit 9a35cd0
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 17 deletions.
18 changes: 3 additions & 15 deletions app/components/ImageCapture/ImageCapture.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,21 +67,9 @@ console.log('trying to stop video');
ctx.drawImage(video, 350, 20, 600, 700, 0, 0, 300, 350);
this.endImageCapture(video);
canvas.toBlob((blob) => {
let newImg = document.createElement('img');
let att = document.createAttribute("class");
att.value = "user-image";
newImg.setAttributeNode(att);
let url = URL.createObjectURL(blob);

newImg.onload = () =>{
URL.revokeObjectURL(url);
};

newImg.src = url;
document.body.appendChild(newImg);
const faceURL = document.querySelector('.user-image').src;
console.log(faceURL);
})
let faceURL = URL.createObjectURL(blob);
console.log(faceURL);
})
// this.storeData(faceURL);
}
}
Expand Down
25 changes: 23 additions & 2 deletions src/controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ const BASE_URL = `https://westus.api.cognitive.microsoft.com/emotion/v1.0/recogn
const IMAGE_URL = 'localhost:300/image'


function getEmotionAnalysis(req, res, next) {
function getEmotionAnalysis(req, res) {
request({
url: BASE_URL,
method: 'POST',
Expand All @@ -21,6 +21,27 @@ function getEmotionAnalysis(req, res, next) {
})
}

function postImageURL(req, res) { //FIGURE OUT HOW TO INSERT FACEURL FROM IMAGECAPTURE
request({
url: '/API/imageURL',
method: 'POST',
body: JSON.stringify({url: /*FACEURL GOES HERE SOMEHOW!!!*/})
})
function (error, response, body) {
if (!error && response.statusCode == 200) {
res.send(body)
}
})
}

function getImageURL(req, res) { //FIGURE OUT HOW TO GET THE IMAGE URL FROM THE BACKEND
request({
//MAGIC HAPPENS HERE?????????
})
}

module.exports = {
getEmotionAnalysis: getEmotionAnalysis
getEmotionAnalysis: getEmotionAnalysis,
postImageURL: postImageURL,
getImageURL: getImageURL
};
2 changes: 2 additions & 0 deletions src/router.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,7 @@ var router = express.Router();
var controller = require('./controller');

router.post('/emotions', controller.getEmotionAnalysis)
router.post('/API/imageURL', controller.postImageURL)
router.get('/API/imageURL/:url', controller.getImageURL)

module.exports = router;

0 comments on commit 9a35cd0

Please sign in to comment.