Accept both json and raw data payloads for the state of the switch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@app.route("/Outlets/api/outlets/<int:groupNumber>/<int:buttonNumber>",methods=["PUT","POST"]) | |
def update_outlet_state(groupNumber, buttonNumber): | |
state=None | |
if request.json is not None: | |
state=request.json.get("state") | |
else: | |
state=request.data | |
if (state is None): | |
abort(400) | |
if (state.lower() != 'on' and state.lower() != 'off'): | |
abort(400) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment