-
Notifications
You must be signed in to change notification settings - Fork 0
/
tornado_server.py
59 lines (44 loc) · 1.72 KB
/
tornado_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
53
54
55
56
57
58
59
import os.path
import logging
_logger = logging.getLogger(__name__)
from operator import itemgetter
from tornado.web import Application, RequestHandler, StaticFileHandler
from tornado.ioloop import IOLoop
config = {
'DEBUG': True,
'PORT' : 5000
}
from GfxTablet import GfxTabletHandler
class MainHandler(RequestHandler):
def get(self):
self.render("index.html")
def main():
root_dir = os.path.abspath(os.path.split(__file__)[0])
print(root_dir)
app = Application([(r'/gfxtablet', GfxTabletHandler),
#(r'/(index.js|src/.*\.js|node_modules/.*\.js)', StaticFileHandler, {}),
(r'/', MainHandler)],
debug=config.get('DEBUG', False), static_path=root_dir, static_url_prefix='/static/')
_logger.info("app.settings:\n%s" % '\n'.join(['%s: %s' % (k, str(v))
for k, v in sorted(app.settings.items(),
key=itemgetter(0))]))
port = config.get('PORT', 5000)
app.listen(port)
_logger.info("listening on port %d" % port)
_logger.info("press CTRL-C to terminate the server")
_logger.info("""
-----------
G f x T a b l e t
*************************
*********************************
STARTING TORNADO APP!!!!!!!!!!!!!
*********************************
*************************
G f x T a b l e t
-----------
""")
IOLoop.instance().start()
if __name__ == "__main__":
logging.basicConfig(level=(logging.DEBUG if config.get('DEBUG') else logging.INFO),
format="%(asctime)s: %(levelname)s %(name)s %(funcName)s %(lineno)d: %(message)s")
main()