@app.route("/chat/")
def chatting():
return render_template('chatHome.html')
@socketio.on('message')
def handleMessage(msg):
send(msg, broadcast=True, include_self=False)
if __name__ == '__main__':
socketio.run(app, host='0.0.0.0', port=(int)(os.environ.get('PORT', 7001)),
debug=True)
$(document).ready(function() {
var socket = io.connect();
socket.on('message', function(msg) {
$("#messages").append('
'+msg+'
');console.log('Received message');
});
$('#sendbutton').on('click', function() {
socket.send($('#myMessage').val());
$("#rightsend").append('
'+($('#myMessage').val())+'
');$('#myMessage').val('');
});
$("#myMessage").keyup(function(event){
if(event.keyCode == 13){
$("#sendbutton").click();
}
});
});