fix: Improve HTTP response handling and clarify default values in schedule configuration
This commit is contained in:
parent
03766d6b09
commit
73b5a5aefe
@ -50,7 +50,7 @@ class TempWebServer:
|
|||||||
content_length = int(line.split(':')[1].strip())
|
content_length = int(line.split(':')[1].strip())
|
||||||
break
|
break
|
||||||
|
|
||||||
# If POST request with body, read remaining data
|
# If POST request with body, read remaining data
|
||||||
if 'POST' in request and content_length > 0:
|
if 'POST' in request and content_length > 0:
|
||||||
# Check how much body we already have
|
# Check how much body we already have
|
||||||
header_end = request.find('\r\n\r\n') + 4
|
header_end = request.find('\r\n\r\n') + 4
|
||||||
@ -175,8 +175,13 @@ class TempWebServer:
|
|||||||
|
|
||||||
elif 'GET /ping' in request:
|
elif 'GET /ping' in request:
|
||||||
# Quick health check endpoint (no processing)
|
# Quick health check endpoint (no processing)
|
||||||
conn.sendall(b'HTTP/1.1 200 OK\r\nContent-Type: text/plain\r\nConnection: close\r\n\r\n')
|
body = b'OK'
|
||||||
conn.sendall(b'OK')
|
conn.sendall(b'HTTP/1.1 200 OK\r\n')
|
||||||
|
conn.sendall(b'Content-Type: text/plain\r\n')
|
||||||
|
conn.sendall(b'Content-Length: 2\r\n')
|
||||||
|
conn.sendall(b'Connection: close\r\n')
|
||||||
|
conn.sendall(b'\r\n')
|
||||||
|
conn.sendall(body)
|
||||||
conn.close()
|
conn.close()
|
||||||
return
|
return
|
||||||
|
|
||||||
@ -187,7 +192,7 @@ class TempWebServer:
|
|||||||
response = self._get_status_page(sensors, ac_monitor, heater_monitor, schedule_monitor)
|
response = self._get_status_page(sensors, ac_monitor, heater_monitor, schedule_monitor)
|
||||||
|
|
||||||
# ===== START: Send response with proper HTTP headers =====
|
# ===== START: Send response with proper HTTP headers =====
|
||||||
print("DEBUG: Sending response ({} bytes)".format(len(response)))
|
print("DEBUG: Sending response ({} bytes)".format(len(response.encode('utf-8'))))
|
||||||
try:
|
try:
|
||||||
# Check if response already has HTTP headers (like redirects)
|
# Check if response already has HTTP headers (like redirects)
|
||||||
if response.startswith('HTTP/1.1'):
|
if response.startswith('HTTP/1.1'):
|
||||||
@ -1379,8 +1384,8 @@ document.addEventListener('DOMContentLoaded', function() {{
|
|||||||
schedules.append({
|
schedules.append({
|
||||||
'time': '',
|
'time': '',
|
||||||
'name': '',
|
'name': '',
|
||||||
'ac_target': config.get('ac_target', 75.0), # ✅ Uses 78°F from config
|
'ac_target': config.get('ac_target', 75.0), # default if not set
|
||||||
'heater_target': config.get('heater_target', 72.0) # ✅ Uses 70°F from config
|
'heater_target': config.get('heater_target', 72.0) # default if not set
|
||||||
})
|
})
|
||||||
|
|
||||||
# ===== DEBUG: Verify we have 4 schedules =====
|
# ===== DEBUG: Verify we have 4 schedules =====
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user