-
Notifications
You must be signed in to change notification settings - Fork 3
/
server.py
32 lines (24 loc) · 854 Bytes
/
server.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
from tornado.web import Application
from tornado.ioloop import IOLoop
from tornado.httpserver import HTTPServer
from tornado.options import define, options
from logzero import logger
from handlers.users import UsersHandler
from persistence.database import mongo, redisdb
import settings
define('version', default=1)
def make_app():
endpoints = [
(r'/api/v{}/users/?(.*)?'.format(options.version), UsersHandler)
]
return Application(endpoints,
debug=True,
mongo=mongo.MongoDb(),
redis=redisdb.RedisDb())
if __name__ == '__main__':
app = make_app()
settings.config_logs()
http_server = HTTPServer(app)
http_server.listen(settings.APP_PORT)
logger.info('Listening server on port {0}'.format(settings.APP_PORT))
IOLoop.current().start()