Initial commit

This commit is contained in:
Miguel Grinberg
2019-03-19 23:37:30 +00:00
committed by Miguel Grinberg
commit 311a82a444
7 changed files with 478 additions and 0 deletions

19
examples/gpio.py Normal file
View File

@@ -0,0 +1,19 @@
import machine
from microdot import Microdot, redirect, send_file
app = Microdot()
@app.route('/', methods=['GET', 'POST'])
def index(request):
if request.method == 'POST':
if 'set-read' in request.form:
pin = machine.Pin(int(request.form['pin']), machine.Pin.IN)
else:
pin = machine.Pin(int(request.form['pin']), machine.Pin.OUT)
pin.value(0 if 'set-low' in request.form else 1)
return redirect('/')
return send_file('gpio.html')
app.run()