File size: 615 Bytes
766a6ee aee64bb |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
from flask import Flask, request
from flask_socketio import SocketIO, emit
app = Flask(__name__)
socketio = SocketIO(app)
# Variable to be changed
variable = "initial_value"
@app.route('/changeurl=<value>')
def change_url(value):
global variable
variable = value
socketio.emit('change_variable', {'value': variable})
return f"Variable changed to: {variable}"
@socketio.on('connect')
def handle_connect():
print('Client connected')
@socketio.on('disconnect')
def handle_disconnect():
print('Client disconnected')
if __name__ == '__main__':
socketio.run(app,port=7860,host="0.0.0.0") |