Created
August 5, 2014 21:28
-
-
Save danasf/5915e4b797cb16bc8a05 to your computer and use it in GitHub Desktop.
flask io
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from flask import Flask | |
import RPi.GPIO as gpio | |
gpio.setmode(gpio.BCM) | |
led_pin = 16 | |
gpio.setup(led_pin,gpio.OUT) | |
gpio.output(led_pin,False) | |
app = Flask(__name__) | |
@app.route('/') | |
def index(): | |
return 'try /on or /off' | |
@app.route('/on') | |
def turnOn(): | |
gpio.output(led_pin,True) | |
return 'Light On' | |
@app.route('/off') | |
def turnOff(): | |
gpio.output(led_pin,False) | |
return 'Light Off' | |
if __name__ == '__main__': | |
app.run() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment