Update app.js
Browse files
app.js
CHANGED
|
@@ -2145,7 +2145,7 @@ app.get('/ask', async (req, res) => {
|
|
| 2145 |
|
| 2146 |
app.post("/playwright", async (req, res) => {
|
| 2147 |
const { code } = req.body;
|
| 2148 |
-
if (!code) return res.status(400).
|
| 2149 |
|
| 2150 |
try {
|
| 2151 |
let output = [];
|
|
@@ -2161,9 +2161,10 @@ app.post("/playwright", async (req, res) => {
|
|
| 2161 |
const result = await vm.run(wrappedCode, import.meta.url);
|
| 2162 |
if (result) output.push(String(result));
|
| 2163 |
|
| 2164 |
-
|
|
|
|
| 2165 |
} catch (error) {
|
| 2166 |
-
res.status(500).
|
| 2167 |
}
|
| 2168 |
});
|
| 2169 |
|
|
|
|
| 2145 |
|
| 2146 |
app.post("/playwright", async (req, res) => {
|
| 2147 |
const { code } = req.body;
|
| 2148 |
+
if (!code) return res.status(400).send("code is required");
|
| 2149 |
|
| 2150 |
try {
|
| 2151 |
let output = [];
|
|
|
|
| 2161 |
const result = await vm.run(wrappedCode, import.meta.url);
|
| 2162 |
if (result) output.push(String(result));
|
| 2163 |
|
| 2164 |
+
const parsedOutput = JSON.stringify(output.join("\n"));
|
| 2165 |
+
res.send(parsedOutput);
|
| 2166 |
} catch (error) {
|
| 2167 |
+
res.status(500).send(JSON.stringify(error.message));
|
| 2168 |
}
|
| 2169 |
});
|
| 2170 |
|