Raspberry Pi - Web Server and API
Given this Flask route code snippet controlling GPIO pin 17:
What will be the output if you visit
from flask import Flask, request
import RPi.GPIO as GPIO
app = Flask(__name__)
GPIO.setmode(GPIO.BCM)
GPIO.setup(17, GPIO.OUT)
@app.route('/pin17/')
def pin17(state):
if state == 'on':
GPIO.output(17, GPIO.HIGH)
return 'Pin 17 is ON'
elif state == 'off':
GPIO.output(17, GPIO.LOW)
return 'Pin 17 is OFF'
else:
return 'Invalid state' What will be the output if you visit
/pin17/on in the browser?