-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconnect.py
47 lines (38 loc) · 954 Bytes
/
connect.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
from bottle import route, run, template, static_file
import subprocess
import os
import webbrowser
import json
import smc
import realtime
from multiprocessing import Process
myData = {
'herro': {
'args': ['a'],
'calls': ['bye'],
},
'bye':{}
}
@route('/')
def beginCom():
return template('basicD3')
@route('/structure')
def setupFxns():
return json.dumps(smc.getStructure())
@route('/data')
def sendLogs():
return json.dumps(myData)
@route('/realtime')
def sendActions():
return json.dumps(realtime.getActions(), cls=realtime.MyEncoder)
@route('/visuals/:path#.+#', name='static')
def static(path):
return static_file(path, root='./visuals/')
def startServer():
run(host='localhost', port=8080)
#p1 = Process(target = startServer)
#p1.start()
#subprocess.call('python -m webbrowser -t "localhost:8080/data"')
realtime.beginRealtime()
webbrowser.open("http://localhost:8080")
run(host='localhost', port=8080)