Skip to content

Instantly share code, notes, and snippets.

@alkait
Created December 16, 2020 19:16
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 alkait/746db41bce32da7c6632d87b3d776b20 to your computer and use it in GitHub Desktop.
Save alkait/746db41bce32da7c6632d87b3d776b20 to your computer and use it in GitHub Desktop.
Remote door opener python server
import time
import RPi.GPIO as GPIO
import sys
from flask import Flask
from flask_restful import Resource, Api
app = Flask(__name__)
api = Api(app)
class Signaler(Resource):
def get(self):
try:
GPIO.setmode(GPIO.BCM)
GPIO.setup(18, GPIO.OUT)
time.sleep(1)
GPIO.output(18, GPIO.HIGH)
GPIO.cleanup()
except Exception as error:
return {'error': error.message}, 500
return {'error': None}, 200
api.add_resource(Signaler, '/')
if __name__ == '__main__':
app.run(host='0.0.0.0', port=5000)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment