developer28 commited on
Commit
633443e
·
verified ·
1 Parent(s): 3a135c5

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +16 -3
app.py CHANGED
@@ -109,10 +109,23 @@ def extract_stock_info(text):
109
  def save_cookies(file):
110
  if file is None:
111
  return None
 
112
  temp_path = tempfile.mktemp(suffix=".txt")
113
- with open(temp_path, "wb") as f:
114
- f.write(file.read())
115
- return temp_path
 
 
 
 
 
 
 
 
 
 
 
 
116
 
117
  # ✅ Full pipeline with error traceback
118
 
 
109
  def save_cookies(file):
110
  if file is None:
111
  return None
112
+
113
  temp_path = tempfile.mktemp(suffix=".txt")
114
+
115
+ try:
116
+ # Handle both file-like object and NamedString
117
+ if hasattr(file, "read"): # File-like
118
+ with open(temp_path, "wb") as f:
119
+ f.write(file.read())
120
+ else: # NamedString (str path)
121
+ shutil.copy(file, temp_path)
122
+
123
+ return temp_path
124
+
125
+ except Exception as e:
126
+ print(f"❌ Failed to handle cookies.txt: {e}")
127
+ return None
128
+
129
 
130
  # ✅ Full pipeline with error traceback
131