Last active
November 11, 2015 12:23
-
-
Save DeastinY/77f9a228feb85a4336e7 to your computer and use it in GitHub Desktop.
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, render_template, redirect, request,jsonify | |
from flask.ext.navigation import Navigation | |
from lampcontrol import lampcontrol | |
app = Flask(__name__) | |
nav = Navigation(app) | |
# Create Navigation | |
nav.Bar('top', [ | |
nav.Item('Lamps', 'index'), | |
nav.Item('Audio', 'index') | |
]) | |
@app.route('/') | |
def index(): | |
lamps = lampcontrol.getlamps() | |
scenes = lampcontrol.getscenes() | |
return render_template('index.html',list=scenes, lamps=lamps, scenes=scenes) | |
@app.route('/togglelamp', methods=["POST"]) | |
def togglelamp(): | |
lampcontrol.setlamp(**request.get_json()) | |
return jsonify(success=True) | |
if __name__ == '__main__': | |
app.run(debug=True,host='0.0.0.0') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment