-
Notifications
You must be signed in to change notification settings - Fork 47
/
Copy pathmain.py
executable file
·78 lines (69 loc) · 2.26 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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
#!/usr/bin/env python
import os
import asyncio
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 (
ZhihuZhuanlanHandler,
ZhihuStream,
ZhihuTopic,
ZhihuCollectionHandler,
ZhihuUpvoteHandler,
ZhihuQuestionHandler,
StaticZhihuHandler,
V2exCommentHandler,
TGChannelHandler,
JikeUserHandler,
JikeTopicHandler,
MattersCircleHandler,
MattersFeedHandler,
MattersTopicHandler,
MattersUserHandler,
GogsIssueHandler,
)
from morerss.base import MyApp
routers = [
# (r'/static/(.*)', tornado.web.StaticFileHandler, {'path': static_dir}),
(r'/zhihuzhuanlan/([^/]+)', ZhihuZhuanlanHandler),
(r'/zhihu/([^/]+)', ZhihuStream),
(r'/zhihu_topic/([^/]+)', ZhihuTopic),
(r'/zhihu_collection/([^/]+)', ZhihuCollectionHandler),
(r'/zhihu_upvote/([^/]+)', ZhihuUpvoteHandler),
(r'/zhihu_question/([^/]+)', ZhihuQuestionHandler),
(r'/static_zhihu/(\d+)', StaticZhihuHandler),
(r'/v2ex/(\d+)', V2exCommentHandler),
(r'/tg/([^/]+)', TGChannelHandler),
(r'/jike_user/([^/]+)', JikeUserHandler),
(r'/jike_topic/([^/]+)', JikeTopicHandler),
(r'/matters/circle/([^/]+)', MattersCircleHandler),
(r'/matters/feed', MattersFeedHandler),
(r'/matters/topic/([^/]+)', MattersTopicHandler),
(r'/matters/user/([^/]+)', MattersUserHandler),
(r'/gogs/([^/]+)/([^/]+)/([^/]+)/issues/(\d+)', GogsIssueHandler),
]
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 = MyApp(
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)
from morerss.zhihu import _article_fetcher
asyncio.ensure_future(_article_fetcher())
tornado.ioloop.IOLoop.instance().start()
if __name__ == "__main__":
try:
main()
except KeyboardInterrupt:
pass