-
Notifications
You must be signed in to change notification settings - Fork 0
/
routes.js
38 lines (35 loc) · 899 Bytes
/
routes.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
33
34
35
36
37
38
import express from "express";
import brailleMapping from "./braillemap.js";
import signlangMapping from "./signlangmap.js";
const router = express.Router();
router.post("/tobraille", (req, res) => {
try {
let { text } = req.body;
const brailleText = text
.toLowerCase()
.split("")
.map((char) => brailleMapping[char] || char)
.join("");
console.log(brailleText);
res.status(200).json(brailleText);
} catch (err) {
console.log(err);
}
});
router.post("/tosign", (req, res) => {
try {
let { text } = req.body;
const signimg = [];
const temp = text.toLowerCase().split("");
temp.map((x) => {
if (x.match(/^[0-9a-z]+$/) || x == " ") {
signimg.push(signlangMapping[x]);
}
});
console.log(signimg);
res.status(200).json(signimg);
} catch (err) {
console.log(err);
}
});
export default router;