diff --git a/app.py b/app.py index ee1e222..e9d18b5 100644 --- a/app.py +++ b/app.py @@ -190,4 +190,24 @@ def view_bottom_customer(): return "No customer data available.", 400 last_index = len(customer_data) - 1 # 计算最后一条记录的索引 - return redirect(url_for('view_customer', index=last_index)) \ No newline at end of file + return redirect(url_for('view_customer', index=last_index)) + + + +@app.route('/search') +def search_by_email(): + email = request.args.get('email') + if not email: + return "Email address is required.", 400 + + # 遍历 customer_data 查找匹配的邮件地址 + for index, customer in enumerate(customer_data): + for domain, info in customer.items(): + if 'email addresses' in info and isinstance(info['email addresses'], list): + for email_record in info['email addresses']: + if email_record.get('email address') == email: + # 找到匹配的记录,跳转到对应的 index + return redirect(url_for('view_customer', index=index)) + + # 如果没有找到匹配的邮件地址 + return "Email address not found.", 404 diff --git a/templates/edit_customers.html b/templates/edit_customers.html index 4082b9f..795bdce 100644 --- a/templates/edit_customers.html +++ b/templates/edit_customers.html @@ -47,6 +47,14 @@ +
+ + +
+ + +
+
@@ -75,7 +83,15 @@ function goToPage() { const pageIndex = document.getElementById('pageIndex').value; if (pageIndex !== '') { - window.location.href = `/customer/${pageIndex}`; // 跳转到指定记录的路由 + window.location.href = `/customer/${pageIndex}`; + } + } + + // 搜索邮件地址并跳转 + function searchByEmail() { + const email = document.getElementById('emailSearch').value; + if (email) { + window.location.href = `/search?email=${encodeURIComponent(email)}`; } }