Skip to content

Instantly share code, notes, and snippets.

@JosephRedfern
Last active July 1, 2020 13:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save JosephRedfern/b06e96e00d4f09a1f0cadf8ebbb12e14 to your computer and use it in GitHub Desktop.
Save JosephRedfern/b06e96e00d4f09a1f0cadf8ebbb12e14 to your computer and use it in GitHub Desktop.
from flask import Flask
import RPi.GPIO as GPIO
channel = 21
# GPIO setup
GPIO.setmode(GPIO.BCM)
GPIO.setup(channel, GPIO.OUT)
app = Flask(__name__)
# these shouldn't really be GET, idempotency etc.
@app.route('/api/gate/activate')
def open_gate():
GPIO.output(pin, GPIO.HIGH) # activate the gate
@app.route('/api/gate/deactivate')
def open_gate():
GPIO.output(pin, GPIO.LOW) # deactivate the gate
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment