wudysoft commited on
Commit
861a383
·
verified ·
1 Parent(s): 775f3bc

Update app.js

Browse files
Files changed (1) hide show
  1. app.js +4 -4
app.js CHANGED
@@ -2149,12 +2149,12 @@ app.post("/playwright", async (req, res) => {
2149
  const { code, timeout = 300000 } = req.body; // Timeout default 5 menit
2150
  if (!code) return res.status(400).json({ error: "Kode tidak boleh kosong" });
2151
 
2152
- let expressLogs = [];
2153
  const originalLog = console.log;
2154
 
2155
  console.log = (...args) => {
2156
  const message = args.map(arg => (typeof arg === "object" ? JSON.stringify(arg) : arg)).join(" ");
2157
- expressLogs.push(message);
2158
  originalLog.apply(console, args);
2159
  };
2160
 
@@ -2189,11 +2189,11 @@ app.post("/playwright", async (req, res) => {
2189
  await runCode();
2190
 
2191
  const startTime = Date.now();
2192
- while (expressLogs.length === 0 && Date.now() - startTime < timeout) {
2193
  await new Promise(resolve => setTimeout(resolve, 1000));
2194
  }
2195
 
2196
- res.json({ logs: expressLogs });
2197
  } catch (err) {
2198
  res.status(500).json({ error: "Kesalahan saat menjalankan kode", details: err.message });
2199
  }
 
2149
  const { code, timeout = 300000 } = req.body; // Timeout default 5 menit
2150
  if (!code) return res.status(400).json({ error: "Kode tidak boleh kosong" });
2151
 
2152
+ let output = [];
2153
  const originalLog = console.log;
2154
 
2155
  console.log = (...args) => {
2156
  const message = args.map(arg => (typeof arg === "object" ? JSON.stringify(arg) : arg)).join(" ");
2157
+ output.push(message);
2158
  originalLog.apply(console, args);
2159
  };
2160
 
 
2189
  await runCode();
2190
 
2191
  const startTime = Date.now();
2192
+ while (output.length === 0 && Date.now() - startTime < timeout) {
2193
  await new Promise(resolve => setTimeout(resolve, 1000));
2194
  }
2195
 
2196
+ res.json({ output });
2197
  } catch (err) {
2198
  res.status(500).json({ error: "Kesalahan saat menjalankan kode", details: err.message });
2199
  }