jczic / MicroWebSrv

A micro HTTP Web server that supports WebSockets, html/python language templating and routing handlers, for MicroPython (used on Pycom modules & ESP32)
https://github.com/jczic/MicroWebSrv
MIT License
640 stars 115 forks source link

Webserver & GPIO #34

Closed kebsont closed 6 years ago

kebsont commented 6 years ago

Hi, I just discover this microserver, but i don't find a way to interact with GPIO.

I mean, putting a button in my webpage, and interact with my pycom pin through this button.

nevercast commented 6 years ago

If the button posts to an endpoint then you would just use the normal Pycom APIs inside your route handler. So create an endpoint that handles a POST to /toggle, and then in that handler use the Pin class from machine to change the output of the GPIO. https://docs.pycom.io/chapter/firmwareapi/pycom/machine/Pin.html