// send a message from the js to the python socketio
// in here we are sending the text that is in the inputBox
function runBackup(){
input = document.getElementById('beginBackupBtn').value;
var socket = io.connect('http://127.0.0.1:5000');
socket.on('connect', function(){
socket.send(input);
});
};
from flask_socketio import SocketIO, emit, send
app = Flask(__name__)
app.config['SECRET_KEY'] = 'mysecret'
socketio = SocketIO(app)
# getting the message that is sent from the js
@socketio.on('backup')
def handleMessage(msg):
print('Message: ' + msg)
send
<!-- Here is the import that should be in the headr for having the socket enabled in the js -->
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/socket.io/2.2.0/socket.io.js"></script>