我在获取请求时将键/值存储在本地字典EMAIL_INFO
中,然后在发布请求时从字典中调用。出于某种原因,当我提交帖子时,我收到一个错误,即我查看"candidate_email"
的密钥不在我的字典中。这对我来说没有意义。
@app.route('/candidates/messages/<payload>/', methods=['GET', 'POST'])
def message_to_candidate(payload):
EMAIL_INFO = {}
if request.method == 'GET':
s = get_serializer()
try:
candidate_email, company_email = s.loads(payload)
EMAIL_INFO['payload'] = get_activation_link(candidate_email, 'introduction', company_email)
EMAIL_INFO['candidate_email'] = candidate_email
EMAIL_INFO['company_email'] = company_email
EMAIL_INFO['company_link'] = '%s%s' %('www.', company_email.split('@')[1])
except BadSignature:
raise
return render_template('message_to_candidate.html')
else:
EMAIL_INFO["message_to_candidate"] = request.form["message_to_candidate"]
send_email(subject="A company has show interest in you...",
sender="TalentTracker",
recipients=[EMAIL_INFO['candidate_email']],
html_body = render_template("email_message_to_candidate.html", email_info=EMAIL_INFO))
return "Email Sent"