Go to the Home Page
SW TO WEB
.py
# -*- coding: utf-8 -*-
from bottle import run,route,template
import RPi.GPIO as GPIO
GPIO.setmode(GPIO.BCM)
SW1=4
GPIO.setup(SW1,GPIO.IN)
@route("/")
def toppage():
sw1_s=GPIO.input(SW1)
if sw1_s==1:SW1_s="OFF"
if sw1_s==0:SW1_s="ON"
return template("toppage",sw1_c=SW1_s)
try:
run(host="172.16.54.134",port=8080,debug=True)
except:
pass
finally:
GPIO.cleanup()
.html
<!DOCTYPE html>
<html lang="ja">
<head><meta charset="utf-8" http-equiv="refresh" content="1.0;url=/"></head>
<body>
<h1><span style="color:red">SW TO WEB</span></h1>
<p>{{sw1_c}}</p>
</body>
</html>