Spaces:
Sleeping
Sleeping
Update app.js
Browse files
app.js
CHANGED
|
@@ -9,6 +9,7 @@ import sharp from 'sharp';
|
|
| 9 |
import { spawn } from 'child_process';
|
| 10 |
import path from 'path';
|
| 11 |
import { NodeVM } from "vm2";
|
|
|
|
| 12 |
import { createRequire } from "module";
|
| 13 |
const require = createRequire(import.meta.url);
|
| 14 |
|
|
@@ -2247,6 +2248,18 @@ app.post("/playwright/v2", async (req, res) => {
|
|
| 2247 |
}
|
| 2248 |
});
|
| 2249 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2250 |
|
| 2251 |
const PORT = process.env.PORT || 7860;
|
| 2252 |
|
|
|
|
| 9 |
import { spawn } from 'child_process';
|
| 10 |
import path from 'path';
|
| 11 |
import { NodeVM } from "vm2";
|
| 12 |
+
import { CompileFile } from 've-compiler';
|
| 13 |
import { createRequire } from "module";
|
| 14 |
const require = createRequire(import.meta.url);
|
| 15 |
|
|
|
|
| 2248 |
}
|
| 2249 |
});
|
| 2250 |
|
| 2251 |
+
app.post('/compile', async (req, res) => {
|
| 2252 |
+
const { code, language } = req.body;
|
| 2253 |
+
|
| 2254 |
+
try {
|
| 2255 |
+
const output = await CompileFile(language, code);
|
| 2256 |
+
// Extract stdout from the output object
|
| 2257 |
+
const stdout = output.stdout || '';
|
| 2258 |
+
res.json({ output: stdout });
|
| 2259 |
+
} catch (error) {
|
| 2260 |
+
res.status(500).json({ error: error.toString() });
|
| 2261 |
+
}
|
| 2262 |
+
});
|
| 2263 |
|
| 2264 |
const PORT = process.env.PORT || 7860;
|
| 2265 |
|