Add try catch for stopping webserver

This commit is contained in:
Ádám Kovács
2023-11-28 18:05:14 +01:00
parent 7fb0347b84
commit dd92fbc62f

View File

@@ -4,6 +4,7 @@ import socket
import ubinascii
from machine import Pin, I2C
from mcp9808.mcp9808 import RESOLUTION_0_625_C
import mcp9808.mcp9808 as mcp9808
import sht4x.sht4x as sht4x
import bmp390.bmp390 as bmp390
@@ -128,6 +129,7 @@ if devices.count(0x77) > 0:
else:
bmp390 = None
try:
while True:
print('waiting for client')
cl, addr = serverSocket.accept()
@@ -224,3 +226,5 @@ bmp390_time""" + attrs + with_fallback_to_str(time_bmp390, "NaN"))
except OSError as e:
cl.close()
print('connection closed')
except:
serverSocket.close()