diff --git a/flexible_web_server/main.py b/flexible_web_server/main.py index d1855c1..946a292 100644 --- a/flexible_web_server/main.py +++ b/flexible_web_server/main.py @@ -46,9 +46,37 @@ def dummy(): return response_template % body +pin = machine.Pin(9, machine.Pin.OUT) + +def light_on(): + pin.value(1) + body = "You turned a light on!" + return response_template % body + +def light_off(): + pin.value(0) + body = "You turned a light off!" + return response_template % body + +switch_pin = machine.Pin(10, machine.Pin.IN) + +def switch(): + body = "{state: " + str(switch_pin.value()) + "}" + return response_template % body + +adc = machine.ADC(0) + +def light(): + body = "{value: " + str(adc.read()) + "}" + return response_template % body + handlers = { 'time': time, 'dummy': dummy, + 'light_on': light_on, + 'light_off': light_off, + 'switch': switch, + 'light': light, } def main():