Adam Jirkovsky
commited on
Commit
·
f11b825
1
Parent(s):
4d345b8
Captcha test
Browse files
app.py
CHANGED
|
@@ -341,7 +341,7 @@ with demo:
|
|
| 341 |
#upload_button.upload(validate_upload, upload_button, file_input)
|
| 342 |
|
| 343 |
with gr.Group():
|
| 344 |
-
captcha_correct = False
|
| 345 |
image, text = generate_captcha()
|
| 346 |
captcha_img = gr.Image(
|
| 347 |
image,
|
|
@@ -354,11 +354,11 @@ with demo:
|
|
| 354 |
captcha_input = gr.Textbox(placeholder="Enter the text in the image above", show_label=False, container=False)
|
| 355 |
check_button = gr.Button("Validate", interactive=True)
|
| 356 |
captcha_result = gr.Markdown()
|
| 357 |
-
|
| 358 |
-
|
| 359 |
-
|
| 360 |
-
|
| 361 |
-
|
| 362 |
submit_button = gr.Button("Submit Eval", interactive=True)
|
| 363 |
submission_result = gr.Markdown()
|
| 364 |
submit_button.click(
|
|
|
|
| 341 |
#upload_button.upload(validate_upload, upload_button, file_input)
|
| 342 |
|
| 343 |
with gr.Group():
|
| 344 |
+
captcha_correct = gr.State(False)
|
| 345 |
image, text = generate_captcha()
|
| 346 |
captcha_img = gr.Image(
|
| 347 |
image,
|
|
|
|
| 354 |
captcha_input = gr.Textbox(placeholder="Enter the text in the image above", show_label=False, container=False)
|
| 355 |
check_button = gr.Button("Validate", interactive=True)
|
| 356 |
captcha_result = gr.Markdown()
|
| 357 |
+
check_button.click(
|
| 358 |
+
fn = lambda: gr.alert("Correct!" if captcha_input.value == text else "Incorrect!"),
|
| 359 |
+
inputs = [captcha_input, text],
|
| 360 |
+
outputs = [captcha_correct, captcha_result],
|
| 361 |
+
)
|
| 362 |
submit_button = gr.Button("Submit Eval", interactive=True)
|
| 363 |
submission_result = gr.Markdown()
|
| 364 |
submit_button.click(
|