from micropyserver import MicroPyServer import time from machine import Pin, PWM import network import gc _init() gc.collect() Led = Pin(13, Pin.OUT) pwmLed = PWM(Led) wlan_id = "Wi-Fi_Name" wlan_pass = "Wi-Fi_Password" wlan = network.WLAN(network.STA_IF) wlan.active(True) wlan.connect(wlan_id, wlan_pass) time.sleep(1) while wlan.isconnected() == False: pass print('Device IP:', wlan.ifconfig()[0]) def index(request, params): ''' request handler ''' if ('duty' in params): pwmLed.duty(int(params['duty'])) server.send("Duty is: " + params['duty']) else: server.send("No Duty param") server = MicroPyServer() ''' add request handler ''' server.add_route("/", index) ''' start server ''' server.start()