Neon-AI commited on
Commit
2f7596f
·
verified ·
1 Parent(s): 904d421

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +39 -0
app.py ADDED
@@ -0,0 +1,39 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ import asyncio
3
+ from playwright.async_api import async_playwright
4
+
5
+ # A simple log collector
6
+ logs = []
7
+
8
+ async def run_bot(url):
9
+ async with async_playwright() as p:
10
+ browser = await p.chromium.launch(headless=True)
11
+ page = await browser.new_page()
12
+
13
+ # Capture console logs
14
+ page.on("console", lambda msg: logs.append(f"LOG: {msg.text}"))
15
+
16
+ # Capture network requests/responses
17
+ page.on("request", lambda req: logs.append(f"REQ: {req.url}"))
18
+ page.on("response", lambda res: logs.append(f"RES: {res.url} {res.status}"))
19
+
20
+ await page.goto(url)
21
+
22
+ # Inject JS like DevTools
23
+ await page.evaluate("console.log('Injected script running');")
24
+
25
+ await browser.close()
26
+
27
+ st.title("DevTools Bot Dashboard")
28
+
29
+ # Take the link from frontend
30
+ target_url = st.text_input("Enter the URL to monitor:", "https://example.com")
31
+
32
+ if st.button("Run Bot"):
33
+ logs.clear() # clear previous logs
34
+ asyncio.run(run_bot(target_url))
35
+
36
+ # Display logs
37
+ st.subheader("Logs")
38
+ for log in logs:
39
+ st.text(log)