Pranesh64 commited on
Commit
4f81de9
·
verified ·
1 Parent(s): 0c037d5

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +23 -3
app.py CHANGED
@@ -54,6 +54,8 @@ def get_db():
54
  raise
55
 
56
 
 
 
57
  # ================= COOKIES =================
58
 
59
  def load_cookies():
@@ -61,12 +63,30 @@ def load_cookies():
61
  if not XSRF_TOKEN or not BIP_SESSION:
62
  raise Exception("XSRF_TOKEN and BIP_SESSION must be set in environment variables")
63
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
64
  return {
65
- "XSRF-TOKEN": XSRF_TOKEN,
66
- "bip_session": BIP_SESSION
67
  }
68
 
69
-
70
  # ================= GMAIL =================
71
 
72
  def create_token():
 
54
  raise
55
 
56
 
57
+ # ================= COOKIES =================
58
+
59
  # ================= COOKIES =================
60
 
61
  def load_cookies():
 
63
  if not XSRF_TOKEN or not BIP_SESSION:
64
  raise Exception("XSRF_TOKEN and BIP_SESSION must be set in environment variables")
65
 
66
+ # Clean the values - remove any cookie header prefixes
67
+ xsrf_value = XSRF_TOKEN.strip()
68
+ session_value = BIP_SESSION.strip()
69
+
70
+ # Remove "XSRF-TOKEN=" prefix if present
71
+ if xsrf_value.startswith("XSRF-TOKEN="):
72
+ xsrf_value = xsrf_value[12:] # Remove "XSRF-TOKEN="
73
+
74
+ # Remove "bip_session=" prefix if present
75
+ if session_value.startswith("bip_session="):
76
+ session_value = session_value[12:] # Remove "bip_session="
77
+
78
+ # Remove any trailing cookie parts (like "; other_cookie=...")
79
+ if ";" in xsrf_value:
80
+ xsrf_value = xsrf_value.split(";")[0]
81
+
82
+ if ";" in session_value:
83
+ session_value = session_value.split(";")[0]
84
+
85
  return {
86
+ "XSRF-TOKEN": xsrf_value,
87
+ "bip_session": session_value
88
  }
89
 
 
90
  # ================= GMAIL =================
91
 
92
  def create_token():