Skip to content

Instantly share code, notes, and snippets.

@JosephRedfern

JosephRedfern/gate.py

Last active Jul 1, 2020
Embed
What would you like to do?
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