Spaces:
Sleeping
Sleeping
Update index.js
Browse files
index.js
CHANGED
@@ -15,7 +15,7 @@ app.get("/", function (req, res) {
|
|
15 |
res.send("Hello World!!");
|
16 |
});
|
17 |
|
18 |
-
app.post('/compile
|
19 |
const javaCode = req.body.code; // Assuming code is sent as a POST parameter
|
20 |
|
21 |
// Write the Java code to Main.java file
|
@@ -41,86 +41,86 @@ app.post('/compile-java', (req, res) => {
|
|
41 |
});
|
42 |
});
|
43 |
|
44 |
-
app.post("/compile", function (req, res) {
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
}else if (lang == "Python") {
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
});
|
125 |
const port = 7860
|
126 |
app.listen(port, () => { console.log(`Open http://localhost:${port}`) })
|
|
|
15 |
res.send("Hello World!!");
|
16 |
});
|
17 |
|
18 |
+
app.post('/compile', (req, res) => {
|
19 |
const javaCode = req.body.code; // Assuming code is sent as a POST parameter
|
20 |
|
21 |
// Write the Java code to Main.java file
|
|
|
41 |
});
|
42 |
});
|
43 |
|
44 |
+
// app.post("/compile", function (req, res) {
|
45 |
+
// var code = req.body.code;
|
46 |
+
// var input = req.body.input;
|
47 |
+
// var lang = req.body.lang;
|
48 |
+
// console.log(code + " " + input + " " + lang);
|
49 |
|
50 |
+
// try {
|
51 |
+
// if (lang == "Cpp") {
|
52 |
+
// if (!input) {
|
53 |
+
// var envData = {
|
54 |
+
// OS: "linux",
|
55 |
+
// cmd: "g++",
|
56 |
+
// options: { timeout: 10000 },
|
57 |
+
// };
|
58 |
+
// compiler.compileCPP(envData, code, function (data) {
|
59 |
+
// if (data.output) {
|
60 |
+
// res.send(data);
|
61 |
+
// } else {
|
62 |
+
// res.send({ error: data.error });
|
63 |
+
// }
|
64 |
+
// });
|
65 |
+
// } else {
|
66 |
+
// var envData = {
|
67 |
+
// OS: "linux",
|
68 |
+
// cmd: "g++",
|
69 |
+
// options: { timeout: 10000 },
|
70 |
+
// };
|
71 |
+
// compiler.compileCPPWithInput(envData, code, input, function (data) {
|
72 |
+
// if (data.output) {
|
73 |
+
// res.send(data);
|
74 |
+
// } else {
|
75 |
+
// res.send({ error: data.error });
|
76 |
+
// }
|
77 |
+
// });
|
78 |
+
// }
|
79 |
+
// } else if (lang == "Java") {
|
80 |
+
// if (!input) {
|
81 |
+
// var envData = { OS: "linux" };
|
82 |
+
// compiler.compileJava(envData, code, function (data) {
|
83 |
+
// if (data.output) {
|
84 |
+
// res.send(data);
|
85 |
+
// } else {
|
86 |
+
// res.send({ error: data.error });
|
87 |
+
// }
|
88 |
+
// });
|
89 |
+
// } else {
|
90 |
+
// var envData = { OS: "linux" };
|
91 |
|
92 |
+
// compiler.compileJavaWithInput(envData, code, input, function (data) {
|
93 |
+
// if (data.output) {
|
94 |
+
// res.send(data);
|
95 |
+
// } else {
|
96 |
+
// res.send({ error: data.error });
|
97 |
+
// }
|
98 |
+
// });
|
99 |
+
// }
|
100 |
+
// }else if (lang == "Python") {
|
101 |
+
// if (!input) {
|
102 |
+
// var envData = { OS: "linux" };
|
103 |
+
// compiler.compilePython(envData, code, function (data) {
|
104 |
+
// if (data.output) {
|
105 |
+
// res.send(data);
|
106 |
+
// } else {
|
107 |
+
// res.send({ error: data.error });
|
108 |
+
// }
|
109 |
+
// });
|
110 |
+
// } else {
|
111 |
+
// var envData = { OS: "linux" };
|
112 |
+
// compiler.compilePythonWithInput(envData, code, input, function (data) {
|
113 |
+
// if (data.output) {
|
114 |
+
// res.send(data);
|
115 |
+
// } else {
|
116 |
+
// res.send({ error: data.error });
|
117 |
+
// }
|
118 |
+
// });
|
119 |
+
// }
|
120 |
+
// }
|
121 |
+
// } catch (e) {
|
122 |
+
// console.log("error:" + e);
|
123 |
+
// }
|
124 |
+
// });
|
125 |
const port = 7860
|
126 |
app.listen(port, () => { console.log(`Open http://localhost:${port}`) })
|