Skip to content

Instantly share code, notes, and snippets.

@danasf
Created August 5, 2014 21:28
Show Gist options
  • Save danasf/5915e4b797cb16bc8a05 to your computer and use it in GitHub Desktop.
Save danasf/5915e4b797cb16bc8a05 to your computer and use it in GitHub Desktop.
flask io
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