import netman, socket, network, time from machine import Pin, ADC ssid = 'xxxx' password = 'xxxx' country = 'US' def web_page(): #f = open("33_text.html") #f = open("33_CheckBox.html") #f = open("33_Number.html") f = open("33_Radio.html") x = f.read() x = x.replace('\r\n',' ') return(x) # disconnect if already connected wlan = network.WLAN(network.STA_IF) if(wlan.active()): wlan.active(0) wlan.disconnect() time.sleep(1) wifi_connection = netman.connectWiFi(ssid,password,country) # Open socket addr = socket.getaddrinfo('0.0.0.0', 80)[0][-1] wlan = socket.socket() wlan.bind(addr) wlan.listen(1) print('listening on', addr) a2d0 = ADC(0) a2d1 = ADC(1) a2d4 = ADC(4) k = 3.3 / 65520 B15 = Pin(15, Pin.IN) B14 = Pin(14, Pin.IN) while(1): flag = 0 while(flag == 0): conn, addr = wlan.accept() request = conn.recv(1024) request = request.decode('utf-8') if(request.find('favicon') > 0): print('--------------------') print('Got a connection from %s' % str(addr)) flag = 1 else: response = web_page() conn.send(response) conn.close() n = request.find('php?')+4 request = request[n:] n = request.find('\r\n') request = request[0:n] msg = [] while(request.find('&')>0): n = request.find('&') msg.append(request[0:n]) request = request[n+1:] msg.append(request) for i in range(0,len(msg)): print('msg[',i,'] = ', msg[i]) response = web_page() conn.send(response) conn.close()