python - Raspberry Pi Bottle webserver, change webpage when button is pressed -
i have raspberry pi bottle webserver running. i've connected several reed switches pi. idea when switch activated, server automatic "push" webpage clients. now, when activate switch. first have refresh page before i'm redirected. i've written script 1 switch far. see below script:
from bottle import route, run, template, error bottle import redirect, request, response switch1 = 38 led1 = 40 gpio.setmode(gpio.board) gpio.setup(switch1, gpio.in, pull_up_down=gpio.pud_up) gpio.setup(led1, gpio.out) @route("/") def hello(): if not gpio.input(switch1): gpio.output(led1, true) return template("video1.html") else: gpio.output(led1, false) return template("index.html") @error(404) def error404(error): return("nothing here, keep searching!") run(host='0.0.0.0', port=80)
Comments
Post a Comment