plan291037 commited on
Commit
1303026
·
verified ·
1 Parent(s): 5f72849

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +18 -7
app.py CHANGED
@@ -29,9 +29,16 @@ async def _worker():
29
  @app.on_event("startup")
30
  async def startup():
31
  global drv, queue, worker
32
- drv = Driver(uc=True, headless=True, test=False, incognito=False,
33
- user_data_dir=PROFILE, page_load_strategy="normal",
34
- agent=UA, no_sandbox=True, disable_gpu=True)
 
 
 
 
 
 
 
35
  drv.get("data:text/html,ready")
36
  queue = asyncio.Queue()
37
  worker = asyncio.create_task(_worker())
@@ -42,13 +49,17 @@ async def shutdown():
42
  if worker: worker.cancel()
43
  if drv: drv.quit()
44
 
 
 
 
 
 
 
 
 
45
  @app.post("/open")
46
  async def open_url(payload: OpenPayload, x_opener_key: str | None = Header(default=None)):
47
  if API_KEY and x_opener_key != API_KEY:
48
  raise HTTPException(status_code=401, detail="bad key")
49
  await queue.put(str(payload.url))
50
  return Response(status_code=204)
51
-
52
- @app.get("/healthz")
53
- async def health():
54
- return {"ok": True}
 
29
  @app.on_event("startup")
30
  async def startup():
31
  global drv, queue, worker
32
+ drv = Driver(
33
+ uc=True,
34
+ headless=True,
35
+ incognito=False,
36
+ user_data_dir=PROFILE,
37
+ page_load_strategy="normal",
38
+ agent=UA,
39
+ no_sandbox=True,
40
+ disable_gpu=True,
41
+ )
42
  drv.get("data:text/html,ready")
43
  queue = asyncio.Queue()
44
  worker = asyncio.create_task(_worker())
 
49
  if worker: worker.cancel()
50
  if drv: drv.quit()
51
 
52
+ @app.get("/")
53
+ async def root():
54
+ return {"ok": True}
55
+
56
+ @app.get("/healthz")
57
+ async def health():
58
+ return {"ok": True}
59
+
60
  @app.post("/open")
61
  async def open_url(payload: OpenPayload, x_opener_key: str | None = Header(default=None)):
62
  if API_KEY and x_opener_key != API_KEY:
63
  raise HTTPException(status_code=401, detail="bad key")
64
  await queue.put(str(payload.url))
65
  return Response(status_code=204)