-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
62 lines (41 loc) · 1.1 KB
/
main.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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
from flask import Flask, render_template
from flask_socketio import SocketIO,emit
import json,cppimport
import scramble
clib = cppimport.imp("clib")
app = Flask(__name__,
static_url_path='',
static_folder='static',)
sapp = SocketIO(app)
@app.route("/room")
def room():
return render_template("room.html")
@app.route("/")
def index():
return render_template("index.html")
@sapp.on('getIDR')
def connect(d):
r = d["data"]
print(f"USED ID {r}")
@sapp.on('setEVN')
def sevn(d):
i = int(d["id"])
evn = d["evn"]
clib.set_event(i,evn)
print('setEVN')
emit('change_event',json.dumps({"evn":evn,"rid":str(i)}),broadcast=True)
@sapp.on("update")
def handle_ge(data):
d = json.loads(data['data'])
d['id'] = str(d['id'])
clib.parse(d)
emit("retupdate",[json.dumps(clib.get(int(d["id"]))),int(d["id"])], broadcast=True)
@sapp.on("newr")
def handle_nr(data):
d = int(data['data'])
clib.clear(d)
emit("retupdate",["{}",d], broadcast=True)
event = clib.get_event(d)
scr = scramble.scrambled[event]()
emit("newscramb",[scr,d],broadcast=True)
sapp.run(app,host="0.0.0.0")