-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.py
executable file
·41 lines (32 loc) · 1.03 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
#!/usr/bin/env python
import tornado.httpserver
import tornado.ioloop
import tornado.web
from tornado.options import options
from pymongo import MongoClient
from settings import settings
from urls import url_patterns
class Application(tornado.web.Application):
def __init__(self):
self.database = MongoClient(
host=settings['database']['host'],
port=settings['database']['port']
).get_database(name=settings['database']['name'])
session_settings = dict(
driver="redis",
driver_settings=dict(
host='localhost',
port=6379,
db=0,
max_connections=1024,
)
)
settings.update(session=session_settings)
tornado.web.Application.__init__(self, url_patterns, **settings)
def main():
app = Application()
http_server = tornado.httpserver.HTTPServer(app)
http_server.listen(options.port)
tornado.ioloop.IOLoop.instance().start()
if __name__ == "__main__":
main()