MCPcopy Create free account
hub / github.com/alpha2phi/python-apps / Query

Class Query

grabql-service/backend/main.py:14–33  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

12
13
14class Query(graphene.ObjectType):
15 screenshot = graphene.String(
16 url=graphene.String(default_value="http://www.google.com"),
17 width=graphene.Int(default_value=1024),
18 height=graphene.Int(default_value=768),
19 )
20
21 def resolve_screenshot(self, info, url, width, height):
22 with sync_playwright() as p:
23 browser_type = p.chromium
24 browser = browser_type.launch()
25 page = browser.new_page()
26 page.set_viewport_size({"width": width, "height": height})
27 page.goto(url)
28 img_byte = page.screenshot(full_page=True)
29 # encoded_img = "data:image/png;base64," + base64.b64encode(
30 # img_byte).decode()
31 encoded_img = base64.b64encode(img_byte).decode()
32 browser.close()
33 return encoded_img
34
35
36app = FastAPI(

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected