-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathroot.py
More file actions
executable file
·91 lines (62 loc) · 2.31 KB
/
root.py
File metadata and controls
executable file
·91 lines (62 loc) · 2.31 KB
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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
#!/usr/bin/env python
import os
import cherrypy
from cherrypy.process.plugins import Daemonizer
from jinja2 import Environment, PackageLoader
from ladon.server.wsgi import LadonWSGIApplication
import modules
PATH = os.path.abspath(os.path.dirname(__file__))
os.chdir(PATH)
app = LadonWSGIApplication(['calculator'], [os.path.join(PATH, 'modules')])
env = Environment(loader=PackageLoader('public', 'templates'))
class Root (object) :
settings = modules.Settings()
@cherrypy.expose
def index (self) :
template = env.get_template('index.html')
return template.render(message='Hi There!')
cherrypy.config.update({
'server.socket_host': '0.0.0.0',
'server.socket_port': 8080,
'log.access_file': './log/access.log',
'log.error_file': './log/error.log',
})
config = {
'/': {
'tools.sessions.on': True,
'tools.staticdir.root': PATH
},
'/static': {
'tools.staticdir.on': True,
'tools.staticdir.dir': './public/static'
},
}
from cherrypy import _cptree
from cherrypy.wsgiserver import CherryPyWSGIServer
from cherrypy.process.servers import ServerAdapter
#~ cherrypy.server.unsubscribe()
wsgiapp = cherrypy.Application(modules.Settings())
wsgiServer = CherryPyWSGIServer(('0.0.0.0', 8070), wsgiapp)
ServerAdapter(cherrypy.engine, wsgiServer).subscribe()
wsgiServer = CherryPyWSGIServer(('0.0.0.0', 8090), app)
ServerAdapter(cherrypy.engine, wsgiServer).subscribe()
cherrypy.tree.mount(Root(), '/', config)
Daemonizer(cherrypy.engine).subscribe()
cherrypy.engine.signals.subscribe()
cherrypy.engine.start()
#~ cherrypy.quickstart(Root(), '/', config)
#NOTE how must be done
#~ cherrypy.server.unsubscribe()
#~
#~ from cherrypy import _cptree
#~ from cherrypy.wsgiserver import CherryPyWSGIServer
#~
#~ tree = _cptree.Tree()
#~ app = tree.mount(modules.Settings())
#~
#~ from cherrypy.process.servers import ServerAdapter
#~
#~ wsgiServer = CherryPyWSGIServer(('0.0.0.0', 8090), app.wsgiapp)
#~ ServerAdapter(cherrypy.engine, wsgiServer).subscribe()
#~ Daemonizer(cherrypy.engine).subscribe()
#~ cherrypy.engine.start()