From 9c92be13d9f58b9b0cbd3bd512a3d305da019432 Mon Sep 17 00:00:00 2001 From: wzj <244142824@qq.com> Date: Mon, 16 Jun 2025 12:53:16 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E9=AA=8C=E8=AF=81=E7=A0=81bu?= =?UTF-8?q?g?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app.py | 23 ----------------------- 1 file changed, 23 deletions(-) diff --git a/app.py b/app.py index 94ef79d..ab0290c 100644 --- a/app.py +++ b/app.py @@ -198,29 +198,6 @@ def get_db_connection(): return None -def generate_captcha(): - # 生成6位随机验证码 - captcha_code = ''.join(random.choices(string.ascii_uppercase + string.digits, k=6)) - conn = get_db_connection() - if conn: - try: - cursor = conn.cursor() - # 清除旧的验证码 - cursor.execute("DELETE FROM captcha WHERE created_at < NOW() - INTERVAL 10 MINUTE") - # 插入新验证码 - cursor.execute("INSERT INTO captcha (code) VALUES (%s)", (captcha_code,)) - conn.commit() - return captcha_code - except Error as e: - print(f"Database error: {e}") - return None - finally: - if conn.is_connected(): - cursor.close() - conn.close() - return None - - def verify_captcha(user_input): """验证用户输入的验证码是否正确(只验证最新的4位验证码)""" conn = get_db_connection()