-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmain.py
38 lines (30 loc) · 970 Bytes
/
main.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 python
# -*- coding: utf-8 -*-
import sys
import os
import tornado.httpserver
import tornado.ioloop
import tornado.web
from tornado.options import define, options
from urls import handlers
from data import Trie
version = sys.version_info[0]
if version < 3:
reload(sys)
sys.setdefaultencoding('utf-8')
define('port', default=9600, help='run tornado app on the given port', type=int)
class App(tornado.web.Application):
def __init__(self):
settings = dict(
static_path = os.path.join(os.path.dirname(__file__), "static"),
template_path = os.path.join(os.path.dirname(__file__), "templates"),
)
super(App, self).__init__(handlers, **settings)
def main():
Trie.parseTxt()
tornado.options.parse_command_line()
http_server = tornado.httpserver.HTTPServer(App())
http_server.listen(options.port)
tornado.ioloop.IOLoop.instance().start()
if __name__ == '__main__':
main()