Exemplo n.º 1
0
    #only by sending this page first will the client be connected to the socketio instance
    return render_template('index.html')

@socketio.on('connect', namespace='/test')
def test_connect():
    # need visibility of the global thread object
    global thread

    print('Client connected')

    #Start the random number generator thread only if the thread has not been started before.
    if not thread.isAlive():
        print "Starting Thread"
        thread = RandomThread()
        #chedit: create a daemon thread so it dies when main thread exits
	thread.start()

@socketio.on('disconnect', namespace='/test')
def test_disconnect():
    print('Client disconnected')



if __name__ == '__main__':
	# host = 0.0.0.0 will be open to any device on the network
	#app.run(debug=True, host='0.0.0.0')
	socketio.run(app,debug=True, host='0.0.0.0')



Exemplo n.º 2
0
import sys

try:
    PORT = int(sys.argv[1])
except:
    PORT = 8083

app = Flask(__name__)
app.debug = True
socketio = SocketIO(app)

pool_pump = template.Button("pool_pump", "Pompe Piscine")
pond_pump = template.Button("pond_pump", "Pompe Etang")
thermopompe = template.Button("thermopompe", "Thermopompe Piscine")

socketio.on("pool_pump")(pool_pump.event)
socketio.on("pond_pump")(pond_pump.event)
socketio.on("thermopompe")(thermopompe.event)


@app.route('/')
def index():
    runThreads()
    browser = request.user_agent.browser
    if browser == "chrome":
        template.ChromeBrowser()
    else:
        template.OtherBrowsers()
    return render_template('index.html', **template.context)

Exemplo n.º 3
0

try:
    PORT = int(sys.argv[1])
except:     
    PORT = 8083

app = Flask(__name__)
app.debug = True
socketio = SocketIO(app)

pool_pump = template.Button("pool_pump", "Pompe Piscine")
pond_pump = template.Button("pond_pump", "Pompe Etang")
thermopompe = template.Button("thermopompe", "Thermopompe Piscine")

socketio.on("pool_pump")(pool_pump.event)
socketio.on("pond_pump")(pond_pump.event)
socketio.on("thermopompe")(thermopompe.event)

@app.route('/')
def index():
    runThreads()
    browser = request.user_agent.browser 
    if browser == "chrome":
        template.ChromeBrowser()
    else:
        template.OtherBrowsers()
    return render_template('index.html', **template.context)

def TED_thread():
    ted = SimpleParser()