Last active
May 15, 2016 12:22
-
-
Save LarsBergqvist/8aa02679fe37e5bff0b6232ca29b2dd9 to your computer and use it in GitHub Desktop.
A Flask web api for controlling RC outlets
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
from flask import Flask, jsonify, request | |
from outletdefinitions import outlets | |
import codesender | |
app = Flask(__name__) | |
@app.route("/Outlets/api/outlets", methods=["GET"]) | |
def get_outlets(): | |
return jsonify({"outlets" : outlets}) | |
@app.route("/Outlets/api/outlets/<int:buttonNumber>",methods=['PUT']) | |
def clickButton(buttonNumber): | |
state=request.json.get("state") | |
print(buttonNumber) | |
print(state) | |
codesender.sendCode(buttonNumber,state) | |
return state | |
if __name__ == "__main__": | |
app.debug = True | |
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