-
Notifications
You must be signed in to change notification settings - Fork 1
/
server.py
30 lines (24 loc) · 891 Bytes
/
server.py
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
27
28
29
30
# NOTE: this doesnt account for anything specific to the bot (i.e. delays, random times, optimization needed)
# See both this console and the webs
from flask import Flask, render_template
from flask_socketio import SocketIO, emit
app = Flask(__name__)
# unsafe key lol
app.config['SECRET_KEY'] = 'xxx'
socketio = SocketIO(app)
# realistically the data here is gonna be sent from the bot.
# For this example's sake im gonna be sending mimic data from a client trigger
@socketio.on('trigger_data')
def handle_my_custom_event(json):
print(f"Received: {json}")
emit('pos_data', {
"x": json.get('x'), # int
"y": json.get('y'), # int
"diff": json.get('diff'), # int
"sweep": json.get('sweep') # int[]
})
@app.route('/')
def index():
return render_template('index.html')
if __name__ == '__main__':
socketio.run(app, port=5000, debug=True)