mirror of
https://github.com/librecaptcha/lc-core.git
synced 2025-01-27 13:03:12 -05:00
simple test script
This commit is contained in:
parent
3d147950a4
commit
79c7dcdb56
32
scripts/simpleTest.py
Normal file
32
scripts/simpleTest.py
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
import http.client
|
||||||
|
import json
|
||||||
|
|
||||||
|
conn = http.client.HTTPConnection('localhost', 8888)
|
||||||
|
conn.request("GET", "/v1/token?email=test")
|
||||||
|
response = conn.getresponse()
|
||||||
|
responseStr = response.read()
|
||||||
|
user = json.loads(responseStr)
|
||||||
|
|
||||||
|
params = """{
|
||||||
|
"level": "medium",
|
||||||
|
"media": "image/png",
|
||||||
|
"input_type": "text"
|
||||||
|
}"""
|
||||||
|
|
||||||
|
conn.request("POST", "/v1/captcha", body=params, headers={'access-token': user["token"]})
|
||||||
|
|
||||||
|
response = conn.getresponse()
|
||||||
|
|
||||||
|
if response:
|
||||||
|
responseStr = response.read()
|
||||||
|
captcha = json.loads(responseStr)
|
||||||
|
print(captcha)
|
||||||
|
captchaId = captcha["id"]
|
||||||
|
reply = {"answer": "xyz", "id" : captchaId}
|
||||||
|
conn.request("POST", "/v1/answer", json.dumps(reply))
|
||||||
|
response = conn.getresponse()
|
||||||
|
if response:
|
||||||
|
responseStr = response.read()
|
||||||
|
print(responseStr)
|
||||||
|
|
||||||
|
|
Loading…
x
Reference in New Issue
Block a user