mirror of
https://github.com/csd4ni3l/grass_touching_captcha.git
synced 2026-01-01 04:23:45 +01:00
put challenge completed at the end of submitting a challenge
This commit is contained in:
3
main.py
3
main.py
@@ -118,7 +118,6 @@ def submit_challenge():
|
|||||||
return Response("You havent started a challenge yet.", 400)
|
return Response("You havent started a challenge yet.", 400)
|
||||||
|
|
||||||
detected_text, text_similarity = check_text_similarity(f"{UPLOAD_DIR}/{image_uuid}.{image_type}", challenges[username]["text"])
|
detected_text, text_similarity = check_text_similarity(f"{UPLOAD_DIR}/{image_uuid}.{image_type}", challenges[username]["text"])
|
||||||
challenges[username]['completed'] = True
|
|
||||||
|
|
||||||
if not text_similarity >= MINIMUM_OCR_SIMILARITY:
|
if not text_similarity >= MINIMUM_OCR_SIMILARITY:
|
||||||
return Response(f"The text is incorrect on the image. Similarity: {round(text_similarity * 100, 2)}% Detected Text: {detected_text}")
|
return Response(f"The text is incorrect on the image. Similarity: {round(text_similarity * 100, 2)}% Detected Text: {detected_text}")
|
||||||
@@ -128,6 +127,8 @@ def submit_challenge():
|
|||||||
os.remove(f"{UPLOAD_DIR}/{image_uuid}.{image_type}")
|
os.remove(f"{UPLOAD_DIR}/{image_uuid}.{image_type}")
|
||||||
return Response(f"Imagine not touching grass. Cosine similarity: {grass_touching_similarity}", 401)
|
return Response(f"Imagine not touching grass. Cosine similarity: {grass_touching_similarity}", 401)
|
||||||
|
|
||||||
|
challenges[username]['completed'] = True
|
||||||
|
|
||||||
return Response(f"/uploads/{image_uuid}.{image_type}", 200)
|
return Response(f"/uploads/{image_uuid}.{image_type}", 200)
|
||||||
|
|
||||||
@app.route("/app")
|
@app.route("/app")
|
||||||
|
|||||||
Reference in New Issue
Block a user