Update app.py
Browse files
app.py
CHANGED
|
@@ -77,6 +77,32 @@ for idx, q in enumerate(questions):
|
|
| 77 |
# Convert responses to DataFrame
|
| 78 |
df = pd.DataFrame(responses)
|
| 79 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 80 |
# Navigation Buttons
|
| 81 |
col1, col2 = st.columns([1, 1])
|
| 82 |
with col1:
|
|
|
|
| 77 |
# Convert responses to DataFrame
|
| 78 |
df = pd.DataFrame(responses)
|
| 79 |
|
| 80 |
+
# Email function
|
| 81 |
+
def send_email(dataframe):
|
| 82 |
+
sender_email = "your_email@example.com"
|
| 83 |
+
sender_password = "your_password"
|
| 84 |
+
recipient_email = "recipient@example.com"
|
| 85 |
+
subject = "AI Maturity Model Responses"
|
| 86 |
+
body = dataframe.to_string(index=False)
|
| 87 |
+
|
| 88 |
+
msg = MIMEText(body)
|
| 89 |
+
msg['Subject'] = subject
|
| 90 |
+
msg['From'] = sender_email
|
| 91 |
+
msg['To'] = recipient_email
|
| 92 |
+
|
| 93 |
+
try:
|
| 94 |
+
with smtplib.SMTP("smtp.example.com", 587) as server:
|
| 95 |
+
server.starttls()
|
| 96 |
+
server.login(sender_email, sender_password)
|
| 97 |
+
server.sendmail(sender_email, recipient_email, msg.as_string())
|
| 98 |
+
st.success("Responses submitted successfully!")
|
| 99 |
+
except Exception as e:
|
| 100 |
+
st.error(f"Error sending responses: {e}")
|
| 101 |
+
|
| 102 |
+
# Submit button
|
| 103 |
+
if st.button("Submit Questionnaire"):
|
| 104 |
+
send_email(df)
|
| 105 |
+
|
| 106 |
# Navigation Buttons
|
| 107 |
col1, col2 = st.columns([1, 1])
|
| 108 |
with col1:
|