Spaces:
No application file
No application file
Update app.py
Browse files
app.py
CHANGED
|
@@ -174,7 +174,7 @@ async def _startup():
|
|
| 174 |
|
| 175 |
@app.get("/health")
|
| 176 |
async def health():
|
| 177 |
-
return {"status": "healthy", "timestamp":
|
| 178 |
|
| 179 |
@app.post("/api/browser/launch")
|
| 180 |
async def launch(request: BrowserLaunchRequest):
|
|
@@ -239,7 +239,7 @@ async def screenshot(req: ScreenshotRequest):
|
|
| 239 |
png = await sess["playwright_page"].screenshot(full_page=req.full_page)
|
| 240 |
# Convert to base64
|
| 241 |
b64 = base64.b64encode(png).decode()
|
| 242 |
-
return {"screenshot": b64, "format": "png", "timestamp":
|
| 243 |
except Exception as e:
|
| 244 |
logger.error(f"Error taking screenshot: {e}")
|
| 245 |
raise HTTPException(status_code=500, detail=str(e))
|
|
@@ -342,7 +342,7 @@ async def scrape_content(request: ScrapeRequest):
|
|
| 342 |
elements = soup.select(selector)
|
| 343 |
scraped_data[selector] = [elem.get_text(strip=True) for elem in elements]
|
| 344 |
|
| 345 |
-
return {"data": scraped_data, "timestamp":
|
| 346 |
|
| 347 |
except Exception as e:
|
| 348 |
logger.error(f"Error scraping content: {e}")
|
|
@@ -355,7 +355,7 @@ async def list_sessions():
|
|
| 355 |
for session_id, session_data in browser_instances.items():
|
| 356 |
sessions.append({
|
| 357 |
'session_id': session_id,
|
| 358 |
-
'created_at':
|
| 359 |
'config': session_data['config']
|
| 360 |
})
|
| 361 |
|
|
|
|
| 174 |
|
| 175 |
@app.get("/health")
|
| 176 |
async def health():
|
| 177 |
+
return {"status": "healthy", "timestamp": dt.utcnow().isoformat()}
|
| 178 |
|
| 179 |
@app.post("/api/browser/launch")
|
| 180 |
async def launch(request: BrowserLaunchRequest):
|
|
|
|
| 239 |
png = await sess["playwright_page"].screenshot(full_page=req.full_page)
|
| 240 |
# Convert to base64
|
| 241 |
b64 = base64.b64encode(png).decode()
|
| 242 |
+
return {"screenshot": b64, "format": "png", "timestamp": dt.utcnow().isoformat()}
|
| 243 |
except Exception as e:
|
| 244 |
logger.error(f"Error taking screenshot: {e}")
|
| 245 |
raise HTTPException(status_code=500, detail=str(e))
|
|
|
|
| 342 |
elements = soup.select(selector)
|
| 343 |
scraped_data[selector] = [elem.get_text(strip=True) for elem in elements]
|
| 344 |
|
| 345 |
+
return {"data": scraped_data, "timestamp": dt.now().isoformat()}
|
| 346 |
|
| 347 |
except Exception as e:
|
| 348 |
logger.error(f"Error scraping content: {e}")
|
|
|
|
| 355 |
for session_id, session_data in browser_instances.items():
|
| 356 |
sessions.append({
|
| 357 |
'session_id': session_id,
|
| 358 |
+
'created_at': dt.fromtimestamp(session_data['created_at']).isoformat(),
|
| 359 |
'config': session_data['config']
|
| 360 |
})
|
| 361 |
|