import tinyweb
from machine import Pin
from time import sleep
# Create web server application
app = tinyweb.webserver()
Button=Pin(2,Pin.OUT)
Button.on()
# Index page
@app.route('/')
async def index(request, response):
# Start HTTP response with content-type text/html
await response.start_html()
# Send actual HTML page
await response.send('
Hi George!
Push the garage door button\n')
# Another one, more complicated page
@app.route('/button/')
async def table(request, response,nr):
# Start HTTP response with content-type text/html
Button.off()
sleep(1)
Button.on()
await response.start_html()
await response.send('Hi George!
Button number %s pushed. Go back. Or push it again.\n'%nr)
def run():
print ("running app")
app.run(host='0.0.0.0', port=80)