| | from flask import Flask, request |
| | from flask_socketio import SocketIO, emit |
| |
|
| | app = Flask(__name__) |
| | socketio = SocketIO(app) |
| |
|
| | |
| | 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") |