Bilgiler > Örnek Flask Uygulaması-Raspberry ile Led Yakma Söndürme
Örnek Flask Uygulaması-Raspberry ile Led Yakma Söndürme
from flask import Flask
import RPi.GPIO as GPIO
from time import sleep
GPIO.setmode(GPIO.BCM)
GPIO.setup(4,GPIO.OUT)
GPIO.output(4,GPIO.LOW)
app=Flask(__name__)
@app.route("/")
def index():
return """<html>
<title>My First Page</title>
<body>
<p>
<a href="ledstate/1">4 nolu led'i yakmak icin tikliayin</a>
</br>
<a href="ledstate/0">4 nolu led'i sondurmek icin tikliayin</a></p>
</body>
</html>"""
@app.route("/ledstate/<int:state>")
def yaksondur(state):
if state==1:
GPIO.output(4,GPIO.HIGH)
else:
GPIO.output(4,GPIO.LOW)
return """ledle oynadiniz. tebrikler"
<a href="/">geri git</a>"""
app.run(host="0.0.0.0")
Devrenin Videosu :https://youtu.be/I2QXbXPWBl0
***