rairo commited on
Commit
fffac28
·
verified ·
1 Parent(s): d6e218c

Update main.py

Browse files
Files changed (1) hide show
  1. main.py +22 -8
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 # <-- ADDED IMPORT
21
- from resend import request as resend_request # <-- ADDED IMPORT
22
-
23
- # === SSL CERTIFICATE FIX ===
24
- # Force the Resend library's underlying requests to use a modern certificate bundle.
25
- # This is the secure way to fix "CERTIFICATE_VERIFY_FAILED" errors in environments
26
- # with outdated root certificates (like some container platforms).
27
- resend_request.Requests.set_default_verify(certifi.where())
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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'):