-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.js
35 lines (30 loc) · 982 Bytes
/
app.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
const { execSync } = require('child_process');
const express = require('express');
const app = express();
const port = 3000;
var exec = require('child_process').exec;
app.get('/c-and-cpp', (req, res) => {
// We make sure to uninstall first if ever user has installed clang but with corrupted
try {
execSync('pkg uninstall clang -y');
} catch(e) {
return res.json({ success: false, message: 'Something went wrong in uninstalling clang' });
}
try {
execSync('pkg install clang -y');
} catch(e) {
return res.json({ success: false, message: 'Something went wrong in installing clang' });
}
return res.json({ success: true });
})
app.get('/check-c-and-cpp', (req, res) => {
try {
execSync('gcc -c c/main.c');
return res.json({ success: true });
} catch(e) {
return res.json({ success: false })
}
});
app.listen(port, () => {
console.log(`Example app listening on port ${port}`)
})