-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.js
More file actions
27 lines (19 loc) · 644 Bytes
/
app.js
File metadata and controls
27 lines (19 loc) · 644 Bytes
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
const express = require("express");
const fileUpload = require("express-fileupload");
const faceApiService = require("./faceApiService");
const app = express();
const port = process.env.PORT || 3000;
app.use(fileUpload());
app.post("/upload", async (req, res) => {
const { file } = req.files;
const result = await faceApiService.detect(file.data, file.name);
res.json({
detectedFaces: result.length,
detectedEmotions : result[0].expressions,
url: `http://localhost:3000/out/${file.name}`,
});
});
app.use("/out", express.static("out"));
app.listen(port, () => {
console.log("Server started on port" + port);
});