Spaces:
Build error
Build error
Update app.py
Browse files
app.py
CHANGED
|
@@ -112,51 +112,29 @@ def copy_to_clipboard(text):
|
|
| 112 |
components.html(copy_icon_html, height=60)
|
| 113 |
|
| 114 |
|
| 115 |
-
def
|
| 116 |
-
"""
|
| 117 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 118 |
|
| 119 |
-
|
| 120 |
-
|
| 121 |
-
'Timestamp': [datetime.now()],
|
| 122 |
-
'Name': [name],
|
| 123 |
-
'Email': [email],
|
| 124 |
-
'Feedback': [feedback]
|
| 125 |
-
}
|
| 126 |
-
df = pd.DataFrame(data)
|
| 127 |
|
| 128 |
-
if os.path.exists(feedback_file):
|
| 129 |
-
try:
|
| 130 |
-
# Attempt to load the existing file
|
| 131 |
-
existing_df = pd.read_excel(feedback_file, engine='openpyxl')
|
| 132 |
-
# Append the new feedback
|
| 133 |
-
df = pd.concat([existing_df, df], ignore_index=True)
|
| 134 |
-
except ValueError as e:
|
| 135 |
-
st.error(f"ValueError: {e} - The file might be corrupted or not an Excel file.")
|
| 136 |
-
# Create a new file if reading fails
|
| 137 |
-
df.to_excel(feedback_file, index=False, engine='openpyxl')
|
| 138 |
-
st.success("New feedback file created and feedback saved!")
|
| 139 |
-
return
|
| 140 |
-
except Exception as e:
|
| 141 |
-
st.error(f"Error reading existing feedback file: {e}")
|
| 142 |
-
# Create a new file if reading fails
|
| 143 |
-
df.to_excel(feedback_file, index=False, engine='openpyxl')
|
| 144 |
-
st.success("New feedback file created and feedback saved!")
|
| 145 |
-
return
|
| 146 |
-
else:
|
| 147 |
-
# File doesn't exist, just create it
|
| 148 |
-
df.to_excel(feedback_file, index=False, engine='openpyxl')
|
| 149 |
-
st.success("Feedback file created and feedback saved!")
|
| 150 |
-
return
|
| 151 |
-
|
| 152 |
try:
|
| 153 |
-
|
| 154 |
-
|
| 155 |
-
|
|
|
|
|
|
|
| 156 |
except Exception as e:
|
| 157 |
-
st.error(f"Error
|
| 158 |
-
|
| 159 |
-
|
| 160 |
|
| 161 |
|
| 162 |
def side():
|
|
|
|
| 112 |
components.html(copy_icon_html, height=60)
|
| 113 |
|
| 114 |
|
| 115 |
+
def send_feedback_via_email(name, email, feedback):
|
| 116 |
+
"""Sends an email with feedback details."""
|
| 117 |
+
smtp_server = 'smtp.yourdomain.com' # Replace with GoDaddy SMTP server
|
| 118 |
+
smtp_port = 587 # Typically 587 for TLS, 465 for SSL
|
| 119 |
+
smtp_user = EMAIL_ADDRESS # Replace with your email
|
| 120 |
+
smtp_password = Password # Replace with your SMTP password
|
| 121 |
+
|
| 122 |
+
msg = MIMEMultipart()
|
| 123 |
+
msg['From'] = smtp_user
|
| 124 |
+
msg['To'] = "wajahat698@gmail.com"
|
| 125 |
+
msg['Subject'] = 'Feedback Received'
|
| 126 |
|
| 127 |
+
body = f"Feedback received from {name}:\n\n{feedback}"
|
| 128 |
+
msg.attach(MIMEText(body, 'plain'))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 129 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 130 |
try:
|
| 131 |
+
with smtplib.SMTP(smtp_server, smtp_port) as server:
|
| 132 |
+
server.starttls() # Upgrade the connection to secure
|
| 133 |
+
server.login(smtp_user, smtp_password)
|
| 134 |
+
server.sendmail(smtp_user, email, msg.as_string())
|
| 135 |
+
st.success("Feedback sent via email successfully!")
|
| 136 |
except Exception as e:
|
| 137 |
+
st.error(f"Error sending email: {e}")
|
|
|
|
|
|
|
| 138 |
|
| 139 |
|
| 140 |
def side():
|