diff --git a/blog.py b/blog.py index ea6302c..b9d90e3 100644 --- a/blog.py +++ b/blog.py @@ -48,7 +48,7 @@ def fix_numbered_lists(html): # Find the
tag containing numbered steps paragraphs = soup.find_all('p') for p in paragraphs: - content = p.decode_contents() + content = p.decode_contents() # type: ignore # Check for likely numbered step structure if re.search(r'1\.\s', content): diff --git a/mail.py b/mail.py index 49bb95f..7602622 100644 --- a/mail.py +++ b/mail.py @@ -22,7 +22,11 @@ import os # }' def validateSender(email): - domains = os.getenv("EMAIL_DOMAINS").split(",") + domains = os.getenv("EMAIL_DOMAINS") + if not domains: + return False + + domains = domains.split(",") for domain in domains: if re.match(r".+@" + domain, email): return True @@ -84,8 +88,17 @@ def sendEmail(data): # Sending the email try: - with smtplib.SMTP_SSL(os.getenv("EMAIL_SMTP"), 465) as server: - server.login(os.getenv("EMAIL_USER"), os.getenv("EMAIL_PASS")) + host = os.getenv("EMAIL_SMTP") + user = os.getenv("EMAIL_USER") + password = os.getenv("EMAIL_PASS") + if host is None or user is None or password is None: + return jsonify({ + "status": 500, + "error": "Email server not configured" + }) + + with smtplib.SMTP_SSL(host, 465) as server: + server.login(user, password) server.sendmail(fromEmail, to, msg.as_string()) print("Email sent successfully.") return jsonify({ diff --git a/main.py b/main.py index 9e516d0..8556a76 100644 --- a/main.py +++ b/main.py @@ -17,8 +17,8 @@ class GunicornApp(BaseApplication): def load_config(self): for key, value in self.options.items(): - if key in self.cfg.settings and value is not None: - self.cfg.set(key.lower(), value) + if key in self.cfg.settings and value is not None: # type: ignore + self.cfg.set(key.lower(), value) # type: ignore def load(self): return self.application diff --git a/server.py b/server.py index 3ae9316..49a8235 100644 --- a/server.py +++ b/server.py @@ -16,6 +16,7 @@ import requests from cloudflare import Cloudflare import datetime import qrcode +from qrcode.constants import ERROR_CORRECT_L, ERROR_CORRECT_H import re import binascii import base64 @@ -51,7 +52,7 @@ handshake_scripts = '