-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathstart.py
executable file
·38 lines (31 loc) · 969 Bytes
/
start.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
#!/usr/bin/env python3
from parser import *
from server import Detour, Daemon, WSHandler
import cherrypy
from pathlib import Path
from ws4py.server.cherrypyserver import WebSocketPlugin, WebSocketTool
def main():
cherrypy.config.update({
'server.socket_port': 27900,
'request.show_tracebacks': True,
})
WebSocketPlugin(cherrypy.engine).subscribe()
cherrypy.tools.websocket = WebSocketTool()
curr_folder = str(Path(__file__).parent.absolute())
Daemon(cherrypy.engine).subscribe()
config = {
'/': {
'tools.staticdir.root': curr_folder,
},
'/public': {
'tools.staticdir.on': True,
'tools.staticdir.dir': 'public',
},
'/ws': {
'tools.websocket.on': True,
'tools.websocket.handler_cls': WSHandler,
},
}
cherrypy.quickstart(Detour(curr_folder + '/public'), '/', config)
if __name__ == '__main__':
main()