Skip to content

Commit

Permalink
bippity boppety
Browse files Browse the repository at this point in the history
  • Loading branch information
nchiappari committed Apr 23, 2017
1 parent 842fab2 commit 496c2f2
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
14 changes: 12 additions & 2 deletions app.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
from gevent import monkey
monkey.patch_all()
from flask import Flask
from flask import render_template
from flask import request
from flask_socketio import SocketIO, emit
app = Flask(__name__)
app.config['SECRET_KEY'] = 'secret!'
socketio = SocketIO(app)

@app.route('/')
def index():
Expand All @@ -18,5 +23,10 @@ def dashboard():
sendCommand(command)
return render_template('dashboard.html')

def sendCommand(command):
socketio.emit("channel-a", command)
@socketio.on('channel-a')
def sendCommand(message):
socketio.emit("channel-a", message)

if __name__ == '__main__':
app.debug = True
socketio.run(app, port=5000)
2 changes: 1 addition & 1 deletion templates/index.html
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<script type="text/javascript" src="//cdnjs.cloudflare.com/ajax/libs/socket.io/1.3.6/socket.io.min.js"></script>
<script type="text/javascript" charset="utf-8">
console.log("HERE WE ARE");
var socket = io.connect('http://' + document.domain + ':' + location.port);
socket.on('channel-a', function(message) {
console.log("COMMAND RECEIVED: " + message);
if (message == "displayOn") {

} else if (message == "displayOff") {
Expand Down

0 comments on commit 496c2f2

Please sign in to comment.