forked from lilydjwg/morerssplz
-
Notifications
You must be signed in to change notification settings - Fork 1
/
main.py
executable file
·49 lines (38 loc) · 1.32 KB
/
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
39
40
41
42
43
44
45
46
47
48
49
#!/usr/bin/env python
# vim:fileencoding=utf-8
import os
import sys
topdir = os.path.dirname(os.path.abspath(__file__))
# tmpl_dir = os.path.join(topdir, 'tmpl')
static_dir = os.path.join(topdir, 'static')
import tornado.web
from tornado.options import define, options
from tornado.httpserver import HTTPServer
from morerss import *
routers = [
# (r'/static/(.*)', tornado.web.StaticFileHandler, {'path': static_dir}),
(r'/zhihuzhuanlan/([^/]+)', ZhihuZhuanlanHandler),
(r'/zhihu/([^/]+)', ZhihuStream),
(r'/static_zhihu/(\d+)', StaticZhihuHandler),
(r'/v2ex/(\d+)', V2exCommentHandler),
]
def main():
define("port", default=8000, help="run on the given port", type=int)
define("address", default='', help="run on the given address", type=str)
define("debug", default=False, help="debug mode", type=bool)
tornado.options.parse_command_line()
application = tornado.web.Application(
routers,
gzip=True,
debug=options.debug,
# template_path = tmpl_dir,
# cookie_secret = settings['cookie_secret'],
)
http_server = HTTPServer(application, xheaders=True)
http_server.listen(options.port, address=options.address)
tornado.ioloop.IOLoop.instance().start()
if __name__ == "__main__":
try:
main()
except KeyboardInterrupt:
pass