Skip to content

Commit

Permalink
Merge pull request #11 from TechLabs-Berlin/main-backend-test
Browse files Browse the repository at this point in the history
Sends video from frontend to flask server
  • Loading branch information
Andreyqo authored Mar 5, 2023
2 parents f38c06e + 3f5fc07 commit 1cc1dc3
Show file tree
Hide file tree
Showing 7 changed files with 377 additions and 349 deletions.
1 change: 1 addition & 0 deletions backend/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions backend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
"express": "^4.18.2",
"express-fileupload": "^1.4.0",
"firebase": "^9.17.1",
"form-data": "^4.0.0",
"mongoose": "^6.9.2",
"multer": "^1.4.5-lts.1"
}
Expand Down
29 changes: 25 additions & 4 deletions backend/routes/videos.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,38 @@ const express = require("express");
const router = express.Router();

const multer = require("multer");
const upload = multer({ dest: "./uploads" });
const upload = multer();
const axios = require("axios");
const FormData = require("form-data");

router.post("/upload", upload.single("video"), (req, res) => {
console.log("/videos/upload POST request");
console.log(req.file);
res.send(req.body);
video = req.file;
console.log(video);

// create FormData object and append the file data to it
const formData = new FormData();
formData.append("file", video.buffer, {
filename: video.originalname,
contentType: video.mimetype,
});

// Send the video to flask server
url = "http://localhost:6000/process_video";
axios
.post(url, formData, {
headers: {
"Content-Type": "multipart/form-data",
},
})
.then((res) => console.log(res.data));

// Send the response to frontend
res.send(video);
});

router.post("/upload-feedback", upload.single("video"), (req, res) => {
console.log("/videos/upload-feedback POST request");
console.log(req.file);
res.send(req.body);
});

Expand Down
83 changes: 42 additions & 41 deletions frontend/package.json
Original file line number Diff line number Diff line change
@@ -1,43 +1,44 @@
{
"name": "pose1",
"version": "0.1.0",
"private": true,
"dependencies": {
"@emotion/react": "^11.10.6",
"@emotion/styled": "^11.10.6",
"@mui/material": "^5.11.11",
"@testing-library/jest-dom": "^5.16.5",
"@testing-library/react": "^13.4.0",
"@testing-library/user-event": "^13.5.0",
"firebase": "^9.17.1",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"react-router-hash-link": "^2.4.3",
"react-scripts": "5.0.1",
"web-vitals": "^2.1.4"
},
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject"
},
"eslintConfig": {
"extends": [
"react-app",
"react-app/jest"
]
},
"browserslist": {
"production": [
">0.2%",
"not dead",
"not op_mini all"
],
"development": [
"last 1 chrome version",
"last 1 firefox version",
"last 1 safari version"
]
}
"name": "pose1",
"version": "0.1.0",
"proxy": "http://localhost:5000",
"private": true,
"dependencies": {
"@emotion/react": "^11.10.6",
"@emotion/styled": "^11.10.6",
"@mui/material": "^5.11.11",
"@testing-library/jest-dom": "^5.16.5",
"@testing-library/react": "^13.4.0",
"@testing-library/user-event": "^13.5.0",
"firebase": "^9.17.1",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"react-router-hash-link": "^2.4.3",
"react-scripts": "5.0.1",
"web-vitals": "^2.1.4"
},
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject"
},
"eslintConfig": {
"extends": [
"react-app",
"react-app/jest"
]
},
"browserslist": {
"production": [
">0.2%",
"not dead",
"not op_mini all"
],
"development": [
"last 1 chrome version",
"last 1 firefox version",
"last 1 safari version"
]
}
}
Loading

0 comments on commit 1cc1dc3

Please sign in to comment.