Spaces:
Build error
Build error
Update app.py
Browse files
app.py
CHANGED
|
@@ -111,10 +111,10 @@ def copy_to_clipboard(text):
|
|
| 111 |
def feedback_email(name, email, feedback):
|
| 112 |
"""Sends feedback via email using SMTP."""
|
| 113 |
EMAIL_ADDRESS = os.getenv("EMAIL_ADDRESS")
|
| 114 |
-
EMAIL_PASSWORD = os.getenv("
|
| 115 |
SMTP_SERVER = "smtp.office365.com"
|
| 116 |
SMTP_PORT = 587
|
| 117 |
-
|
| 118 |
if not EMAIL_ADDRESS or not EMAIL_PASSWORD:
|
| 119 |
st.error("Email configuration is missing.")
|
| 120 |
return
|
|
@@ -127,10 +127,6 @@ def feedback_email(name, email, feedback):
|
|
| 127 |
msg.attach(MIMEText(body, 'plain'))
|
| 128 |
|
| 129 |
try:
|
| 130 |
-
# Debugging: Print the email content
|
| 131 |
-
st.write(f"Sending email to {msg['To']} with subject '{msg['Subject']}'")
|
| 132 |
-
st.write(f"Email body:\n{body}")
|
| 133 |
-
|
| 134 |
with smtplib.SMTP(SMTP_SERVER, SMTP_PORT, timeout=10) as server:
|
| 135 |
server.set_debuglevel(1) # Enable debug output
|
| 136 |
server.starttls()
|
|
@@ -183,22 +179,22 @@ def side():
|
|
| 183 |
|
| 184 |
|
| 185 |
feedback_name = st.text_input("Name")
|
|
|
|
| 186 |
feedback_text = st.text_area("Feedback")
|
| 187 |
-
|
| 188 |
# Submit button within the form
|
| 189 |
submit_button = st.form_submit_button("Submit Feedback")
|
| 190 |
if submit_button:
|
| 191 |
-
|
| 192 |
-
if feedback_name and feedback_text:
|
| 193 |
with st.spinner('Sending email'):
|
| 194 |
-
|
| 195 |
-
feedback_email(feedback_name, feedback_text)
|
| 196 |
st.success("Thank you for your feedback!")
|
| 197 |
else:
|
| 198 |
st.error("Please fill in all fields.")
|
| 199 |
|
| 200 |
|
| 201 |
|
|
|
|
| 202 |
side()
|
| 203 |
# Load knowledge base
|
| 204 |
@st.cache_resource
|
|
|
|
| 111 |
def feedback_email(name, email, feedback):
|
| 112 |
"""Sends feedback via email using SMTP."""
|
| 113 |
EMAIL_ADDRESS = os.getenv("EMAIL_ADDRESS")
|
| 114 |
+
EMAIL_PASSWORD = os.getenv("Password") # Ensure this environment variable is set correctly
|
| 115 |
SMTP_SERVER = "smtp.office365.com"
|
| 116 |
SMTP_PORT = 587
|
| 117 |
+
|
| 118 |
if not EMAIL_ADDRESS or not EMAIL_PASSWORD:
|
| 119 |
st.error("Email configuration is missing.")
|
| 120 |
return
|
|
|
|
| 127 |
msg.attach(MIMEText(body, 'plain'))
|
| 128 |
|
| 129 |
try:
|
|
|
|
|
|
|
|
|
|
|
|
|
| 130 |
with smtplib.SMTP(SMTP_SERVER, SMTP_PORT, timeout=10) as server:
|
| 131 |
server.set_debuglevel(1) # Enable debug output
|
| 132 |
server.starttls()
|
|
|
|
| 179 |
|
| 180 |
|
| 181 |
feedback_name = st.text_input("Name")
|
| 182 |
+
feedback_email_input = st.text_input("Email")
|
| 183 |
feedback_text = st.text_area("Feedback")
|
| 184 |
+
|
| 185 |
# Submit button within the form
|
| 186 |
submit_button = st.form_submit_button("Submit Feedback")
|
| 187 |
if submit_button:
|
| 188 |
+
if feedback_name and feedback_email_input and feedback_text:
|
|
|
|
| 189 |
with st.spinner('Sending email'):
|
| 190 |
+
feedback_email(feedback_name, feedback_email_input, feedback_text)
|
|
|
|
| 191 |
st.success("Thank you for your feedback!")
|
| 192 |
else:
|
| 193 |
st.error("Please fill in all fields.")
|
| 194 |
|
| 195 |
|
| 196 |
|
| 197 |
+
|
| 198 |
side()
|
| 199 |
# Load knowledge base
|
| 200 |
@st.cache_resource
|