-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathserver.py
More file actions
44 lines (37 loc) · 1.31 KB
/
server.py
File metadata and controls
44 lines (37 loc) · 1.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
import cherrypy
import os
from controllers import Root, Upload, SearchGenerator, Download
def get_app_config():
return {
'/': {
'tools.sessions.on': True,
'tools.staticdir.root': os.path.abspath(os.getcwd()),
},
'/static': {
'tools.staticdir.on': True,
'tools.staticdir.dir': './public'
}
}
def get_app(config=None):
config = config or get_app_config()
root = Root()
root.download = Download()
cherrypy.tree.mount(root, '/', config="config/webapp.cfg")
cherrypy.tree.mount(Upload(), '/upload', config="config/webapp.cfg")
cherrypy.tree.mount(SearchGenerator(), '/generate', config="config/webapp.cfg")
if __name__ == '__main__':
import tornado
import tornado.httpserver
import tornado.wsgi
get_app()
wsgiapp = cherrypy.tree
cherrypy.config.update({'engine.autoreload.on': False})
cherrypy.server.unsubscribe()
cherrypy.engine.signals.subscribe()
cherrypy.log.error_log.propagate = False
cherrypy.engine.start()
container = tornado.wsgi.WSGIContainer(wsgiapp)
http_server = tornado.httpserver.HTTPServer(container)
http_server.listen(8080)
tornado.ioloop.PeriodicCallback(lambda: cherrypy.engine.publish('main'), 100).start()
tornado.ioloop.IOLoop.instance().start()