From b5433fa1d6370c3381c599edb0a5e7b7ecdfc02c Mon Sep 17 00:00:00 2001 From: hailin Date: Mon, 28 Oct 2024 20:33:40 +0800 Subject: [PATCH] . --- app.py | 90 +++++++++++++++++++++++++++++----------------------------- 1 file changed, 45 insertions(+), 45 deletions(-) diff --git a/app.py b/app.py index 6232de7..2515f2d 100644 --- a/app.py +++ b/app.py @@ -103,51 +103,6 @@ def calculate_statistics(): return total_emails, cold_lead_count, no_promotion_count -@app.route('/customer/') -def view_customer(index): - # 判断是否有数据 - if not customer_data: - return "No customer data provided.", 400 - - # 确保 index 在合法范围内 - if index < 0 or index >= len(customer_data): - return "Index out of range.", 400 - - customer = customer_data[index] - - # 为每个 email addresses 列表中的项添加唯一的索引 - for domain, info in customer.items(): - print(f"..........domain={domain}") - print(f"..........info={info}") - if 'email addresses' in info and isinstance(info['email addresses'], list): - for email_idx, email in enumerate(info['email addresses']): - email['idx'] = email_idx # 给每个 email 项添加唯一的索引 - - is_first = index == 0 - is_last = index == len(customer_data) - 1 - - # 调试代码:先尝试返回不带统计信息的模板渲染 - return render_template('edit_customers.html', - customer=customer, - index=index, - is_first=is_first, - is_last=is_last) - - # 计算统计数据 - total_emails, cold_lead_count, no_promotion_count = calculate_statistics() - - return render_template('edit_customers.html', - customer=customer, - index=index, - is_first=is_first, - is_last=is_last, - total_emails=total_emails, - cold_lead_count=cold_lead_count, - no_promotion_count=no_promotion_count) - - - - # @app.route('/customer/') # def view_customer(index): # # 判断是否有数据 @@ -171,12 +126,57 @@ def view_customer(index): # is_first = index == 0 # is_last = index == len(customer_data) - 1 +# # 调试代码:先尝试返回不带统计信息的模板渲染 # return render_template('edit_customers.html', # customer=customer, # index=index, # is_first=is_first, # is_last=is_last) +# # 计算统计数据 +# total_emails, cold_lead_count, no_promotion_count = calculate_statistics() + +# return render_template('edit_customers.html', +# customer=customer, +# index=index, +# is_first=is_first, +# is_last=is_last, +# total_emails=total_emails, +# cold_lead_count=cold_lead_count, +# no_promotion_count=no_promotion_count) + + + + +@app.route('/customer/') +def view_customer(index): + # 判断是否有数据 + if not customer_data: + return "No customer data provided.", 400 + + # 确保 index 在合法范围内 + if index < 0 or index >= len(customer_data): + return "Index out of range.", 400 + + customer = customer_data[index] + + # 为每个 email addresses 列表中的项添加唯一的索引 + for domain, info in customer.items(): + print(f"..........domain={domain}") + print(f"..........info={info}") + if 'email addresses' in info and isinstance(info['email addresses'], list): + for email_idx, email in enumerate(info['email addresses']): + email['idx'] = email_idx # 给每个 email 项添加唯一的索引 + + is_first = index == 0 + is_last = index == len(customer_data) - 1 + + return render_template('edit_customers.html', + customer=customer, + index=index, + is_first=is_first, + is_last=is_last) + @app.route('/update/', methods=['POST'])