-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrouter.js
More file actions
59 lines (52 loc) · 1.42 KB
/
router.js
File metadata and controls
59 lines (52 loc) · 1.42 KB
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
import express from "express";
// import WaitQueue from "wait-queue";
// const wq = new WaitQueue();
import {
cExecuter,
pythonExecuter,
cppExecuter,
javascriptExecuter,
javaExecuter,
deleteFile,
} from "./compiler/compiler.js";
const router = express.Router();
router.get("/", (req, res) => {
res.json({ msg: "code" });
});
let op = "";
router.post("/", async (req, res) => {
if (req.body.lang === "c") {
cExecuter(req.body.code, req.body.input).then((data) => {
// console.log(data);
// deleteFile("code.c");
res.json(data);
});
} else if (req.body.lang === "cpp") {
cppExecuter(req.body.code, req.body.input).then((data) => {
// console.log(data);
// deleteFile("code.c");
res.json(data);
});
} else if (req.body.lang === "python") {
pythonExecuter(req.body.code, req.body.input).then((data) => {
// console.log(data);
// deleteFile("code.c");
res.json(data);
});
} else if (req.body.lang === "javascript") {
javascriptExecuter(req.body.code, req.body.input).then((data) => {
// console.log(data);
// deleteFile("code.c");
res.json(data);
});
} else if (req.body.lang === "java") {
javaExecuter(req.body.code, req.body.input).then((data) => {
// console.log(data);
// deleteFile("code.c");
res.json(data);
});
} else {
res.json({ error: "Invalid language" });
}
});
export { router };