-
Notifications
You must be signed in to change notification settings - Fork 14
/
Copy pathapp.py
executable file
·64 lines (56 loc) · 2.08 KB
/
app.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
# coding: UTF-8
import asyncio
import tornado.auth
import tornado.httpserver
import tornado.ioloop
import tornado.options
import tornado.web
import tornado.autoreload
from tornado.options import define, options
from handlers import *
import session
from settings import settings
from cache import RedisCacheBackend
import redis
define("port", default=8888, help="run on the given port", type=int)
define("debug", default=True, help="debug mode", type=bool)
define("mongo_host", default="127.0.0.1:27017", help="database host")
class Application(tornado.web.Application):
def __init__(self):
handlers = [
(r"/", HomeHandler),
(r"/logout", LogoutHandler),
(r"/webhook", WebhookHandler),
(r"/callback", CallbackHandler),
(r"/stars", UserStarHandler),
(r"/follows", UserFollowingHandler),
(r"/cities", UserCityhandler),
(r"/f", FollowHandler),
(r"/uf", UnfollowHandler),
(r"/add", AddWebhookHandler),
(r"/show", ShowHandler),
(r"/login", LoginHandler),
(r"/howitworks", HowHandler),
(r"/stat", StatHandler),
(r"/users", StatUserHandler),
(r"/repos", StatRepoHandler),
(r"/export", ExportHandler),
]
self.session_manager = session.TornadoSessionManager(settings["session_secret"], settings["session_dir"])
self.redis = redis.Redis()
self.cache = RedisCacheBackend(self.redis)
debug = False
tornado.web.Application.__init__(self, handlers, **settings)
# async def main():
# tornado.options.parse_command_line()
# application = tornado.web.Application([(r"/", MainHandler)])
# http_server = tornado.httpserver.HTTPServer(application)
# http_server.listen(options.port)
# await asyncio.Event().wait()
async def main():
tornado.options.parse_command_line()
http_server = tornado.httpserver.HTTPServer(Application())
http_server.listen(options.port)
await asyncio.Event().wait()
if __name__ == "__main__":
asyncio.run(main())