Initial commit
This commit is contained in:
19
examples/gpio.py
Normal file
19
examples/gpio.py
Normal 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()
|
||||
Reference in New Issue
Block a user