Advertisement
Guest User

Untitled

a guest
Oct 14th, 2019
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.79 KB | None | 0 0
  1. import RPi.GPIO as GPIO
  2. import time
  3. import sys
  4. from flask import request
  5. from flask_api import FlaskAPI
  6.  
  7. app = FlaskAPI(__name__)
  8.  
  9. led_pin = 21 # Initializing pin 40 for led
  10. GPIO.setmode(GPIO.BCM) # Using BCM numbering
  11. GPIO.setup(led_pin, GPIO.OUT) # Declaring the pin 40 as output pin
  12. print("initialized")
  13.  
  14. @app.route('/',methods=["GET"])
  15. def turn_on_led():
  16. print("called succesfully")
  17. GPIO.output(led_pin, True)
  18. time.sleep(0.2)
  19. GPIO.output(led_pin, False)
  20. time.sleep(0.2)
  21. GPIO.output(led_pin, True)
  22. time.sleep(0.2)
  23. GPIO.output(led_pin, False)
  24. time.sleep(0.2)
  25. GPIO.output(led_pin, True)
  26. time.sleep(0.2)
  27. GPIO.output(led_pin, False)
  28. return {
  29. "Response":"alert shown"
  30. }
  31.  
  32. if __name__ == "__main__":
  33. app.run()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement