zuehue commited on
Commit
766a6ee
·
verified ·
1 Parent(s): 5e25821

Create main.py

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