Skip to content

Instantly share code, notes, and snippets.

@DeastinY
Last active November 11, 2015 12:23
Show Gist options
  • Save DeastinY/77f9a228feb85a4336e7 to your computer and use it in GitHub Desktop.
Save DeastinY/77f9a228feb85a4336e7 to your computer and use it in GitHub Desktop.
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