Spaces:
Sleeping
Sleeping
Update main.py
Browse files
main.py
CHANGED
|
@@ -17,14 +17,28 @@ import random
|
|
| 17 |
from datetime import datetime as dt_class, timezone
|
| 18 |
from zoneinfo import ZoneInfo
|
| 19 |
import pandas as pd
|
| 20 |
-
import certifi
|
| 21 |
-
|
| 22 |
-
|
| 23 |
-
|
| 24 |
-
#
|
| 25 |
-
# This is the
|
| 26 |
-
#
|
| 27 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 28 |
|
| 29 |
# === Logging Configuration ===
|
| 30 |
if not os.path.exists('logs'):
|
|
|
|
| 17 |
from datetime import datetime as dt_class, timezone
|
| 18 |
from zoneinfo import ZoneInfo
|
| 19 |
import pandas as pd
|
| 20 |
+
import certifi
|
| 21 |
+
import requests # <-- ADDED IMPORT
|
| 22 |
+
import functools # <-- ADDED IMPORT
|
| 23 |
+
|
| 24 |
+
# === MONKEY-PATCH FOR SSL CERTIFICATE FIX ===
|
| 25 |
+
# This is the definitive solution to the SSL/TLS verification issue.
|
| 26 |
+
# It intercepts any web request made by the `requests` library (which `resend` uses)
|
| 27 |
+
# and forces it to use the modern certificate bundle from `certifi`.
|
| 28 |
+
|
| 29 |
+
# 1. Store the original `request` method
|
| 30 |
+
original_request = requests.request
|
| 31 |
+
|
| 32 |
+
# 2. Create a new patched method
|
| 33 |
+
@functools.wraps(original_request)
|
| 34 |
+
def patched_request(*args, **kwargs):
|
| 35 |
+
# 3. If 'verify' is not already set, set it to the certifi bundle path
|
| 36 |
+
kwargs.setdefault('verify', certifi.where())
|
| 37 |
+
# 4. Call the original method with the potentially modified arguments
|
| 38 |
+
return original_request(*args, **kwargs)
|
| 39 |
+
|
| 40 |
+
# 5. Replace the original method in the `requests` library with our patched version
|
| 41 |
+
requests.request = patched_request
|
| 42 |
|
| 43 |
# === Logging Configuration ===
|
| 44 |
if not os.path.exists('logs'):
|