Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -63,9 +63,6 @@ def send_email(to_email, subject, body):
|
|
| 63 |
|
| 64 |
logging.info(f"Email sent to {to_email}")
|
| 65 |
return True
|
| 66 |
-
except smtplib.SMTPAuthenticationError as auth_error:
|
| 67 |
-
logging.error(f"SMTP Authentication Error: {auth_error}")
|
| 68 |
-
raise Exception(f"Failed to send email: Invalid credentials or app-specific password required.")
|
| 69 |
except Exception as e:
|
| 70 |
logging.error(f"Email error: {e}")
|
| 71 |
raise Exception(f"Failed to send email: {str(e)}")
|
|
@@ -146,18 +143,18 @@ def book_appointment(name, email, date, time, timezone, message):
|
|
| 146 |
"datasets": [{
|
| 147 |
"label": "Appointment",
|
| 148 |
"data": [1],
|
| 149 |
-
"backgroundColor": "#
|
| 150 |
-
"borderColor": "#
|
| 151 |
"borderWidth": 2
|
| 152 |
}]
|
| 153 |
},
|
| 154 |
"options": {
|
| 155 |
"scales": {
|
| 156 |
-
"y": {"beginAtZero": True, "ticks": {"stepSize": 1, "color": "#
|
| 157 |
-
"x": {"title": {"display": True, "text": "Date & Time", "color": "#
|
| 158 |
},
|
| 159 |
"plugins": {
|
| 160 |
-
"title": {"display": True, "text": f"Appointment for {name}", "color": "#
|
| 161 |
}
|
| 162 |
}
|
| 163 |
}
|
|
@@ -177,8 +174,8 @@ JS_ENHANCEMENT = """
|
|
| 177 |
document.addEventListener('DOMContentLoaded', function() {
|
| 178 |
const dateDropdown = document.querySelector('select[id*="date"]');
|
| 179 |
if (dateDropdown) {
|
| 180 |
-
dateDropdown.style.background = '#
|
| 181 |
-
dateDropdown.style.border = '2px solid #
|
| 182 |
dateDropdown.style.borderRadius = '8px';
|
| 183 |
dateDropdown.style.padding = '12px';
|
| 184 |
dateDropdown.style.fontSize = '16px';
|
|
@@ -186,7 +183,7 @@ document.addEventListener('DOMContentLoaded', function() {
|
|
| 186 |
Array.from(dateDropdown.options).forEach(option => {
|
| 187 |
if (option.value.includes(today)) {
|
| 188 |
option.style.fontWeight = 'bold';
|
| 189 |
-
option.style.color = '#
|
| 190 |
}
|
| 191 |
});
|
| 192 |
}
|
|
@@ -199,34 +196,33 @@ with gr.Blocks(theme=gr.themes.Soft(), css="""
|
|
| 199 |
.gradio-container {
|
| 200 |
max-width: 700px;
|
| 201 |
margin: 20px auto;
|
| 202 |
-
background: #
|
| 203 |
padding: 24px;
|
| 204 |
border-radius: 16px;
|
| 205 |
-
box-shadow: 0 4px 16px rgba(0,0,0,0.
|
| 206 |
}
|
| 207 |
.welcome {
|
| 208 |
text-align: center;
|
| 209 |
font-size: 28px;
|
| 210 |
-
color: #
|
| 211 |
margin: 0 0 20px;
|
| 212 |
font-weight: 700;
|
| 213 |
}
|
| 214 |
.gr-textbox, .gr-dropdown {
|
| 215 |
border-radius: 8px;
|
| 216 |
-
border: 2px solid #
|
| 217 |
padding: 12px;
|
| 218 |
font-size: 16px;
|
| 219 |
-
background:
|
| 220 |
-
color: #4E342E; /* Dark brown text */
|
| 221 |
transition: border-color 0.2s;
|
| 222 |
}
|
| 223 |
.gr-textbox:focus, .gr-dropdown:focus {
|
| 224 |
-
border-color: #
|
| 225 |
outline: none;
|
| 226 |
}
|
| 227 |
.gr-button {
|
| 228 |
-
background: #
|
| 229 |
-
color:
|
| 230 |
font-size: 16px;
|
| 231 |
font-weight: 600;
|
| 232 |
padding: 12px 32px;
|
|
@@ -237,26 +233,26 @@ with gr.Blocks(theme=gr.themes.Soft(), css="""
|
|
| 237 |
transition: background 0.2s;
|
| 238 |
}
|
| 239 |
.gr-button:hover {
|
| 240 |
-
background: #
|
| 241 |
}
|
| 242 |
.gr-textbox[label="Result"] {
|
| 243 |
-
background: #
|
| 244 |
-
border-color: #
|
| 245 |
-
color: #
|
| 246 |
font-weight: 500;
|
| 247 |
padding: 16px;
|
| 248 |
border-radius: 8px;
|
| 249 |
}
|
| 250 |
.gr-column {
|
| 251 |
-
background:
|
| 252 |
padding: 20px;
|
| 253 |
border-radius: 12px;
|
| 254 |
-
box-shadow: 0 2px 8px rgba(0,0,0,0.
|
| 255 |
}
|
| 256 |
.footer {
|
| 257 |
text-align: center;
|
| 258 |
font-size: 14px;
|
| 259 |
-
color: #
|
| 260 |
margin-top: 20px;
|
| 261 |
}
|
| 262 |
.logo {
|
|
@@ -266,18 +262,7 @@ with gr.Blocks(theme=gr.themes.Soft(), css="""
|
|
| 266 |
}
|
| 267 |
.required::after {
|
| 268 |
content: " *";
|
| 269 |
-
color: #D32F2F;
|
| 270 |
-
}
|
| 271 |
-
p {
|
| 272 |
-
text-align: center;
|
| 273 |
-
color: #FFFFFF !important; /* White text for instructions */
|
| 274 |
-
}
|
| 275 |
-
a {
|
| 276 |
-
color: #EFEBE9 !important; /* Soft beige for links */
|
| 277 |
-
text-decoration: none;
|
| 278 |
-
}
|
| 279 |
-
a:hover {
|
| 280 |
-
text-decoration: underline;
|
| 281 |
}
|
| 282 |
@media (max-width: 600px) {
|
| 283 |
.gradio-container {
|
|
@@ -296,7 +281,7 @@ with gr.Blocks(theme=gr.themes.Soft(), css="""
|
|
| 296 |
f"""
|
| 297 |
<img src="https://ik.imagekit.io/kqeykkpy5/WhatsApp_Image_2024-12-20_at_02.57.39-removebg-preview.png?updatedAt=1747857266922" class="logo" alt="Mubashir Hussain Logo">
|
| 298 |
<div class="welcome">Schedule Your Appointment</div>
|
| 299 |
-
<p>Select a date and time below to book with Mubashir Hussain. You'll receive a confirmation email with a Google Calendar link.</p>
|
| 300 |
{JS_ENHANCEMENT}
|
| 301 |
"""
|
| 302 |
)
|
|
@@ -313,7 +298,7 @@ with gr.Blocks(theme=gr.themes.Soft(), css="""
|
|
| 313 |
|
| 314 |
gr.Markdown(
|
| 315 |
"""
|
| 316 |
-
<div class="footer">Powered by <a href="https://mubashirdev.com">mubashirdev.com</a></div>
|
| 317 |
"""
|
| 318 |
)
|
| 319 |
|
|
|
|
| 63 |
|
| 64 |
logging.info(f"Email sent to {to_email}")
|
| 65 |
return True
|
|
|
|
|
|
|
|
|
|
| 66 |
except Exception as e:
|
| 67 |
logging.error(f"Email error: {e}")
|
| 68 |
raise Exception(f"Failed to send email: {str(e)}")
|
|
|
|
| 143 |
"datasets": [{
|
| 144 |
"label": "Appointment",
|
| 145 |
"data": [1],
|
| 146 |
+
"backgroundColor": "#003087",
|
| 147 |
+
"borderColor": "#001F5C",
|
| 148 |
"borderWidth": 2
|
| 149 |
}]
|
| 150 |
},
|
| 151 |
"options": {
|
| 152 |
"scales": {
|
| 153 |
+
"y": {"beginAtZero": True, "ticks": {"stepSize": 1, "color": "#333"}, "title": {"display": True, "text": "Confirmed", "color": "#333"}},
|
| 154 |
+
"x": {"title": {"display": True, "text": "Date & Time", "color": "#333"}, "ticks": {"color": "#333"}}
|
| 155 |
},
|
| 156 |
"plugins": {
|
| 157 |
+
"title": {"display": True, "text": f"Appointment for {name}", "color": "#003087", "font": {"size": 18}}
|
| 158 |
}
|
| 159 |
}
|
| 160 |
}
|
|
|
|
| 174 |
document.addEventListener('DOMContentLoaded', function() {
|
| 175 |
const dateDropdown = document.querySelector('select[id*="date"]');
|
| 176 |
if (dateDropdown) {
|
| 177 |
+
dateDropdown.style.background = '#E6F0FA';
|
| 178 |
+
dateDropdown.style.border = '2px solid #003087';
|
| 179 |
dateDropdown.style.borderRadius = '8px';
|
| 180 |
dateDropdown.style.padding = '12px';
|
| 181 |
dateDropdown.style.fontSize = '16px';
|
|
|
|
| 183 |
Array.from(dateDropdown.options).forEach(option => {
|
| 184 |
if (option.value.includes(today)) {
|
| 185 |
option.style.fontWeight = 'bold';
|
| 186 |
+
option.style.color = '#003087';
|
| 187 |
}
|
| 188 |
});
|
| 189 |
}
|
|
|
|
| 196 |
.gradio-container {
|
| 197 |
max-width: 700px;
|
| 198 |
margin: 20px auto;
|
| 199 |
+
background: #E6F0FA;
|
| 200 |
padding: 24px;
|
| 201 |
border-radius: 16px;
|
| 202 |
+
box-shadow: 0 4px 16px rgba(0,0,0,0.1);
|
| 203 |
}
|
| 204 |
.welcome {
|
| 205 |
text-align: center;
|
| 206 |
font-size: 28px;
|
| 207 |
+
color: #003087;
|
| 208 |
margin: 0 0 20px;
|
| 209 |
font-weight: 700;
|
| 210 |
}
|
| 211 |
.gr-textbox, .gr-dropdown {
|
| 212 |
border-radius: 8px;
|
| 213 |
+
border: 2px solid #003087;
|
| 214 |
padding: 12px;
|
| 215 |
font-size: 16px;
|
| 216 |
+
background: white;
|
|
|
|
| 217 |
transition: border-color 0.2s;
|
| 218 |
}
|
| 219 |
.gr-textbox:focus, .gr-dropdown:focus {
|
| 220 |
+
border-color: #001F5C;
|
| 221 |
outline: none;
|
| 222 |
}
|
| 223 |
.gr-button {
|
| 224 |
+
background: #003087;
|
| 225 |
+
color: white;
|
| 226 |
font-size: 16px;
|
| 227 |
font-weight: 600;
|
| 228 |
padding: 12px 32px;
|
|
|
|
| 233 |
transition: background 0.2s;
|
| 234 |
}
|
| 235 |
.gr-button:hover {
|
| 236 |
+
background: #001F5C;
|
| 237 |
}
|
| 238 |
.gr-textbox[label="Result"] {
|
| 239 |
+
background: #E8F5E9;
|
| 240 |
+
border-color: #2E7D32;
|
| 241 |
+
color: #1B5E20;
|
| 242 |
font-weight: 500;
|
| 243 |
padding: 16px;
|
| 244 |
border-radius: 8px;
|
| 245 |
}
|
| 246 |
.gr-column {
|
| 247 |
+
background: white;
|
| 248 |
padding: 20px;
|
| 249 |
border-radius: 12px;
|
| 250 |
+
box-shadow: 0 2px 8px rgba(0,0,0,0.05);
|
| 251 |
}
|
| 252 |
.footer {
|
| 253 |
text-align: center;
|
| 254 |
font-size: 14px;
|
| 255 |
+
color: #003087;
|
| 256 |
margin-top: 20px;
|
| 257 |
}
|
| 258 |
.logo {
|
|
|
|
| 262 |
}
|
| 263 |
.required::after {
|
| 264 |
content: " *";
|
| 265 |
+
color: #D32F2F;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 266 |
}
|
| 267 |
@media (max-width: 600px) {
|
| 268 |
.gradio-container {
|
|
|
|
| 281 |
f"""
|
| 282 |
<img src="https://ik.imagekit.io/kqeykkpy5/WhatsApp_Image_2024-12-20_at_02.57.39-removebg-preview.png?updatedAt=1747857266922" class="logo" alt="Mubashir Hussain Logo">
|
| 283 |
<div class="welcome">Schedule Your Appointment</div>
|
| 284 |
+
<p style="text-align: center; color: #333;">Select a date and time below to book with Mubashir Hussain. You'll receive a confirmation email with a Google Calendar link.</p>
|
| 285 |
{JS_ENHANCEMENT}
|
| 286 |
"""
|
| 287 |
)
|
|
|
|
| 298 |
|
| 299 |
gr.Markdown(
|
| 300 |
"""
|
| 301 |
+
<div class="footer">Powered by <a href="https://mubashirdev.com" style="color: #003087; text-decoration: none;">mubashirdev.com</a></div>
|
| 302 |
"""
|
| 303 |
)
|
| 304 |
|