@@ -156,6 +156,13 @@ def do_POST(self):
156156 """Handle POST requests."""
157157 parsed_path = urlparse (self .path )
158158
159+ # Early debug log to see if we're getting to this point
160+ try :
161+ with open ('/tmp/wifi_debug_start.log' , 'a' ) as f :
162+ f .write (f"POST request received to { parsed_path .path } \n " )
163+ except Exception as e :
164+ print (f"Error writing to start debug log: { e } " )
165+
159166 if parsed_path .path == "/api/settings" :
160167 try :
161168 # Read the request body
@@ -164,11 +171,14 @@ def do_POST(self):
164171 settings_data = json .loads (post_data )
165172
166173 # Write all settings being processed to debug file
167- with open ('/tmp/wifi_debug.log' , 'a' ) as f :
174+ try :
175+ with open ('/tmp/wifi_debug.log' , 'a' ) as f :
168176 f .write ("===== SETTINGS UPDATE =====\n " )
169177 for k , v in settings_data .items ():
170- f .write (f"Key: { k } , Value type: { type (v )} , Value: { v } \n " )
178+ f .write (f"Key: { k } , Value type: { type (v )} , Value: { v } \n " )
171179 f .write ("========================\n " )
180+ except Exception as e :
181+ print (f"Error writing to debug log: { e } " )
172182
173183 # Update settings
174184 for key , value in settings_data .items ():
@@ -186,8 +196,11 @@ def do_POST(self):
186196 if key == 'WIFI_NETWORKS' :
187197 try :
188198 # Write debug info to a file that can be checked later
189- with open ('/tmp/wifi_debug.log' , 'a' ) as f :
199+ try :
200+ with open ('/tmp/wifi_debug.log' , 'a' ) as f :
190201 f .write (f"WIFI_NETWORKS value type: { type (value )} , value: { value } \n " )
202+ except Exception as e :
203+ print (f"Error writing to wifi debug log: { e } " )
191204 # Parse the value to ensure it's in the correct format
192205 if isinstance (value , str ):
193206 networks = json .loads (value )
0 commit comments