Created
February 7, 2017 08:04
-
-
Save LarsBergqvist/d219189cbebf98e0416985f927d9ef91 to your computer and use it in GitHub Desktop.
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