def StartServer(app=None, socketio=None, host=None, port=DEFAULT_PORT, debug=True):
    if socketio is None: socketio = SOCKET_IO_CORE
    if host is None:
        if debug:
            host = '0.0.0.0'
        else:
            host = '127.0.0.1'
    Thread(target=background_thread).start()
    logWarning("Starting Socket App1")
    try:
        logWarning(host)
        logWarning(port)
        socketio.run(app, host=host, port=port)
    except Exception as err:
        logError("Error: Could not start socketio.")
        DB_CONNECTION.close()
Beispiel #2
0
def launch():
    # Start the thread that will emit video frames as they arrive
    start_video_thread(flask.ext.socketio)

    # Start the web app
    socketio.run(app, host="0.0.0.0", port=8000)
Beispiel #3
0
def launch():
    # Start the thread that will emit video frames as they arrive
    start_video_thread(flask.ext.socketio)

    # Start the web app
    socketio.run(app, host='0.0.0.0', port=8000)
Beispiel #4
0
from flask import Flask
import flask
from flask.ext.socketio import SocketIO, emit
import flask.ext.socketio

#NO LONGER NEEDED. REFERENCE ONLY

app = Flask(__name__)
socketio = SocketIO(app)

@app.route('/persons/<string:person>')
def get_persons(person):
	adj='mean gangsta'
	return flask.render_template('index.html',person=person,adj=adj)

# Broadcast
@socketio.on('my broadcast event',namespace='/test')
def test_message(message):
	emit('my response',{'data': message['data']}, broadcast=True)

@socketio.on('connect',namespace='/test')
def test_connect():
	emit('my response',{'data':'Connected'})

@socketio.on('disconnect',namespace='/test')
def test_disconnect():
	emit('my response',{'data':'Disconnected'})

if __name__=='__main__':
	socketio.run(app)
    return render_template('notify.html')

@app.route('/<device>/<service>/<characteristic>/unnotify')
def unnotify():
    """disable notify to stop insanity"""
    pass

@app.route('/message/<data>')
def message(data):
    socketio.send(data)
    return 'Just sent ' + data

# WebSocket communication
@socketio.on('connect')
def connect(data):
    app.logger.info('%s has connected', data)
    emit('yo', {'data': 'Connected'})

@socketio.on('disconnect')
def disconnect():
    app.logger.info('%s has disconnected.')

@socketio.on('message')
def message(data):
    app.logger.info('Received a message containing: %s', data)

if __name__ == '__main__':
    app.debug = True
    # app.run(host='0.0.0.0', debug=True)
    socketio.run(app, host='0.0.0.0')