Forgets commited on
Commit
ed1b19a
·
verified ·
1 Parent(s): a823344

Create api_test.py

Browse files
Files changed (1) hide show
  1. api_test.py +41 -0
api_test.py ADDED
@@ -0,0 +1,41 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import asyncio
2
+ import httpx
3
+
4
+ async def main():
5
+ # Gunakan timeout yang cukup lama karena Puppeteer butuh waktu untuk bypass
6
+ # Jika di lokal/server, sesuaikan URL-nya
7
+ base_url = "http://localhost:7860"
8
+
9
+ limits = httpx.Limits(max_keepalive_connections=5, max_connections=10)
10
+
11
+ async with httpx.AsyncClient(timeout=120.0, limits=limits) as client:
12
+ print("--- Testing Mode: IUAM ---")
13
+ try:
14
+ resp1 = await client.post(
15
+ f"{base_url}/cloudflare",
16
+ json={
17
+ "domain": "https://olamovies.watch/generate",
18
+ "mode": "iuam",
19
+ },
20
+ )
21
+ # Menggunakan .get() agar tidak error jika respon bukan JSON
22
+ print(resp1.status_code, resp1.json())
23
+ except Exception as e:
24
+ print(f"Error pada IUAM: {e}")
25
+
26
+ print("\n--- Testing Mode: Turnstile ---")
27
+ try:
28
+ resp2 = await client.post(
29
+ f"{base_url}/cloudflare",
30
+ json={
31
+ "domain": "https://lksfy.com/",
32
+ "siteKey": "0x4AAAAAAA49NnPZwQijgRoi",
33
+ "mode": "turnstile",
34
+ },
35
+ )
36
+ print(resp2.status_code, resp2.json())
37
+ except Exception as e:
38
+ print(f"Error pada Turnstile: {e}")
39
+
40
+ if __name__ == "__main__":
41
+ asyncio.run(main())