forked from acgx/ooi2
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ooi.py
53 lines (49 loc) · 2 KB
/
ooi.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
import tornado.httpserver
import tornado.ioloop
import tornado.web
from tornado.options import define, options, parse_command_line
from ooi.handlers import MainHandler, NormalGameHandler, IFrameGameHandler, IFrameFlashHandler, \
PoiGameHandler, ReloginHandler, MaintainHandler
from api.handlers import ApiHandler, MainSwfHandler, WorldImageHandler
from auth.handlers import OsapiHandler, TokenHandler
from config import template_path, static_path, cookie_secret
from ui import modules
define('port', type=int, default=8000)
define('mp', type=bool, default=False)
define('debug', type=bool, default=False)
define('maintain', type=bool, default=False)
define('service', type=bool, default=False)
if __name__ == "__main__":
parse_command_line()
if options.maintain:
handlers = [('/', MaintainHandler), ]
else:
handlers = [('/', MainHandler),
('/kancolle', NormalGameHandler),
('/iframe', IFrameGameHandler),
('/flash', IFrameFlashHandler),
('/poi', PoiGameHandler),
(r'/kcsapi/(.*)', ApiHandler),
('/kcs/mainD2.swf', MainSwfHandler),
(r'/kcs/resources/image/world/.*(l|s)\.png', WorldImageHandler),
('/relogin', ReloginHandler), ]
if options.service:
handlers += [('/service/osapi', OsapiHandler),
('/service/token', TokenHandler), ]
application = tornado.web.Application(
handlers=handlers,
template_path=template_path,
static_path=static_path,
cookie_secret=cookie_secret,
ui_modules=modules,
compress_response=True,
debug=options.debug
)
if options.debug or not options.mp:
application.listen(options.port)
tornado.ioloop.IOLoop.current().start()
else:
server = tornado.httpserver.HTTPServer(application)
server.bind(options.port)
server.start(0)
tornado.ioloop.IOLoop.current().start()