Adam Jirkovsky
commited on
Commit
·
6463eb6
1
Parent(s):
daf8b12
Make captcha case-insensitive
Browse files
app.py
CHANGED
@@ -157,7 +157,7 @@ def validate_upload(input):
|
|
157 |
raise gr.Error("Cannot parse file")
|
158 |
|
159 |
|
160 |
-
def generate_captcha(width=
|
161 |
text = ''.join(random.choices(string.ascii_uppercase + string.digits, k=length))
|
162 |
captcha_obj = ImageCaptcha(width, height)
|
163 |
data = captcha_obj.generate(text)
|
@@ -167,7 +167,7 @@ def generate_captcha(width=200, height=150, length=4):
|
|
167 |
|
168 |
def validate_captcha(input, text, img):
|
169 |
img, new_text = generate_captcha()
|
170 |
-
if input == text:
|
171 |
return True, styled_message("Correct! You can procede with your submission."), new_text, img, ""
|
172 |
return False, styled_error("Incorrect! Please retry with the new code."), new_text, img, ""
|
173 |
|
|
|
157 |
raise gr.Error("Cannot parse file")
|
158 |
|
159 |
|
160 |
+
def generate_captcha(width=300, height=220, length=4):
|
161 |
text = ''.join(random.choices(string.ascii_uppercase + string.digits, k=length))
|
162 |
captcha_obj = ImageCaptcha(width, height)
|
163 |
data = captcha_obj.generate(text)
|
|
|
167 |
|
168 |
def validate_captcha(input, text, img):
|
169 |
img, new_text = generate_captcha()
|
170 |
+
if input.lower() == text.lower():
|
171 |
return True, styled_message("Correct! You can procede with your submission."), new_text, img, ""
|
172 |
return False, styled_error("Incorrect! Please retry with the new code."), new_text, img, ""
|
173 |
|