Spaces:
Sleeping
Sleeping
Update server.js
Browse files
server.js
CHANGED
|
@@ -47,19 +47,19 @@ async function extract(url, res){
|
|
| 47 |
app.get ('/extract',(req,res)=>extract(req.query.url,res));
|
| 48 |
app.post('/extract',(req,res)=>extract(req.body.url,res));
|
| 49 |
|
| 50 |
-
/* POST /login {
|
| 51 |
-
app.post('/login', async (
|
| 52 |
-
|
| 53 |
-
return res.status(401).json({ error: 'unauthorized' });*/
|
| 54 |
|
| 55 |
-
|
| 56 |
-
|
| 57 |
-
|
| 58 |
|
| 59 |
-
const
|
| 60 |
-
|
| 61 |
-
|
| 62 |
-
|
|
|
|
| 63 |
});
|
| 64 |
|
| 65 |
console.log('🛰️ Public URL will be:', HOSTNAME);
|
|
|
|
| 47 |
app.get ('/extract',(req,res)=>extract(req.query.url,res));
|
| 48 |
app.post('/extract',(req,res)=>extract(req.body.url,res));
|
| 49 |
|
| 50 |
+
/* POST /login → { ok, screenshot_b64 } */
|
| 51 |
+
app.post('/login', async (_req, res) => {
|
| 52 |
+
const out = await runLogin();
|
|
|
|
| 53 |
|
| 54 |
+
if (!out.ok) {
|
| 55 |
+
return res.status(500).json(out);
|
| 56 |
+
}
|
| 57 |
|
| 58 |
+
const b64 = out.png.toString('base64');
|
| 59 |
+
res.json({
|
| 60 |
+
ok: true,
|
| 61 |
+
screenshot_b64: 'data:image/png;base64,' + b64.slice(0), // ready for <img src=...>
|
| 62 |
+
});
|
| 63 |
});
|
| 64 |
|
| 65 |
console.log('🛰️ Public URL will be:', HOSTNAME);
|