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()