Jason commited on
Commit
26d3547
·
1 Parent(s): 799a0ac
Files changed (1) hide show
  1. features/captcha.py +5 -5
features/captcha.py CHANGED
@@ -14,8 +14,8 @@ if config['DEFAULT']['prod'] == 'True':
14
  else:
15
  URL = config['DEVELOPMENT']['URL']
16
 
17
- def req(filename):
18
- r = requests.post(f'{URL}/captcha', json={'target': filename})
19
 
20
  if r.status_code == 200:
21
  res = r.json()
@@ -35,7 +35,7 @@ def run():
35
  fig, axes = plt.subplots(6,4, layout="constrained", figsize=(15,15))
36
 
37
  for option, ax, index in zip(res['options'], axes.ravel(), range(23)):
38
- filename = option[0]
39
  image_base64 = option[1]
40
  image = Image.open(BytesIO(decodebytes(bytes(image_base64, "ascii"))))
41
  ax.imshow(image)
@@ -48,5 +48,5 @@ def run():
48
  st.pyplot(fig)
49
 
50
  for index, option in enumerate(res['options']):
51
- filename = option[0]
52
- st.button(label=f'Click image {index + 1}', key=index+1, on_click=req, kwargs={"filename": filename})
 
14
  else:
15
  URL = config['DEVELOPMENT']['URL']
16
 
17
+ def req(target_uuid):
18
+ r = requests.post(f'{URL}/captcha', json={'target_uuid': target_uuid})
19
 
20
  if r.status_code == 200:
21
  res = r.json()
 
35
  fig, axes = plt.subplots(6,4, layout="constrained", figsize=(15,15))
36
 
37
  for option, ax, index in zip(res['options'], axes.ravel(), range(23)):
38
+ candidate_uuid = option[0]
39
  image_base64 = option[1]
40
  image = Image.open(BytesIO(decodebytes(bytes(image_base64, "ascii"))))
41
  ax.imshow(image)
 
48
  st.pyplot(fig)
49
 
50
  for index, option in enumerate(res['options']):
51
+ candidate_uuid = option[0]
52
+ st.button(label=f'Click image {index + 1}', key=index+1, on_click=req, kwargs={"target_uuid": candidate_uuid})