This commit is contained in:
parent
a1d3bc7c7e
commit
5c582904dc
22
app.py
22
app.py
|
|
@ -190,4 +190,24 @@ def view_bottom_customer():
|
||||||
return "No customer data available.", 400
|
return "No customer data available.", 400
|
||||||
|
|
||||||
last_index = len(customer_data) - 1 # 计算最后一条记录的索引
|
last_index = len(customer_data) - 1 # 计算最后一条记录的索引
|
||||||
return redirect(url_for('view_customer', index=last_index))
|
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
|
||||||
|
|
|
||||||
|
|
@ -47,6 +47,14 @@
|
||||||
<button onclick="goToPage()">Go to Page</button>
|
<button onclick="goToPage()">Go to Page</button>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<hr>
|
||||||
|
|
||||||
|
<!-- 搜索邮件地址的输入框和按钮 -->
|
||||||
|
<div>
|
||||||
|
<input type="text" id="emailSearch" placeholder="Enter email address">
|
||||||
|
<button onclick="searchByEmail()">Search by Email</button>
|
||||||
|
</div>
|
||||||
|
|
||||||
<hr>
|
<hr>
|
||||||
|
|
||||||
<!-- 原有的上一页和下一页按钮 -->
|
<!-- 原有的上一页和下一页按钮 -->
|
||||||
|
|
@ -75,7 +83,15 @@
|
||||||
function goToPage() {
|
function goToPage() {
|
||||||
const pageIndex = document.getElementById('pageIndex').value;
|
const pageIndex = document.getElementById('pageIndex').value;
|
||||||
if (pageIndex !== '') {
|
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)}`;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue