-
Notifications
You must be signed in to change notification settings - Fork 2
/
run_server.py
executable file
·54 lines (43 loc) · 1.16 KB
/
run_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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
import cherrypy
import os
class Root:
def __init__(self):
pass
@cherrypy.expose()
def old(self):
return load_html('data-browser.html')
@cherrypy.expose(['index'])
def new(self):
html = load_html('data-browser.html')
html = html.replace('js/demo_old.js', 'js/demo_new.js')
return html
def load_html(file_name):
lines = open(os.path.join(MEDIA_DIR, file_name), "r").readlines()
return "".join(lines)
MEDIA_DIR = os.path.join(os.path.abspath("."))
QUICKSTART_CONFIG = {
"/": {
"tools.staticdir.root": MEDIA_DIR,
"tools.etags.on": True,
"tools.etags.autotags": True,
"tools.gzip.on": True
},
"/css": {
"tools.staticdir.on": True,
"tools.staticdir.dir": "css"
},
"/js": {
"tools.staticdir.on": True,
"tools.staticdir.dir": "js"
},
"/data": {
"tools.staticdir.on": True,
"tools.staticdir.dir": "data"
},
}
if __name__ == "__main__":
cherrypy.config.update({
"server.socket_host": "0.0.0.0",
"server.socket_port": 80,
})
cherrypy.quickstart(Root(), "", config=QUICKSTART_CONFIG)