kfahn commited on
Commit
41ed7f9
·
verified ·
1 Parent(s): 615ec88

Update app.py

Browse files

yet another try

Files changed (1) hide show
  1. app.py +9 -11
app.py CHANGED
@@ -72,29 +72,27 @@ def my_custom_tool(arg1:str, arg2:int)-> str: #it's import to specify the return
72
  # print("Screenshot saved!")
73
 
74
  async def capture_screenshot():
75
- """Launches Playwright and captures a screenshot of a p5.js sketch."""
76
  print("Launching Playwright...")
77
  async with async_playwright() as p:
78
  browser = await p.chromium.launch(headless=True)
79
  page = await browser.new_page()
80
-
81
- print("Opening the p5.js sketch...")
82
- #https://raw.githubusercontent.com/your-username/repository-name/branch-name/path/to/image.png
83
 
84
- await page.goto("https://raw.githubusercontent.com/kfahn22/Op-Art/blob/main/assets/gears.jpg", timeout=60000) # Increased timeout
 
 
85
 
86
- print("Waiting for page to load fully...")
87
- await page.wait_for_load_state("networkidle") # Ensures all requests finish
88
 
89
- print("Waiting for canvas element...")
90
- await page.wait_for_selector("canvas", timeout=60000) # Increased timeout
91
 
92
  print("Capturing screenshot...")
93
  await page.screenshot(path="img.png")
94
  await browser.close()
95
  print("Screenshot saved!")
96
-
97
-
98
  @tool
99
  def grab_image() -> Image:
100
  """
 
72
  # print("Screenshot saved!")
73
 
74
  async def capture_screenshot():
75
+ """Launches Playwright and captures a screenshot of an image from GitHub."""
76
  print("Launching Playwright...")
77
  async with async_playwright() as p:
78
  browser = await p.chromium.launch(headless=True)
79
  page = await browser.new_page()
 
 
 
80
 
81
+ # Use the raw GitHub image URL
82
+ #https://github.com/kfahn22/Op-Art/blob/main/assets/gears.jpg
83
+ image_url = "https://raw.githubusercontent.com/kfahn22/repository-name/Op-Art/main/assets/gears.jpg"
84
 
85
+ print(f"Opening image from GitHub: {image_url}")
86
+ await page.goto(image_url, timeout=120000) # Wait for the image page to load
87
 
88
+ print("Waiting for image element...")
89
+ await page.wait_for_selector("img", timeout=120000) # Wait for the <img> to be visible
90
 
91
  print("Capturing screenshot...")
92
  await page.screenshot(path="img.png")
93
  await browser.close()
94
  print("Screenshot saved!")
95
+
 
96
  @tool
97
  def grab_image() -> Image:
98
  """