-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.py
46 lines (37 loc) · 1.44 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
import tornado.ioloop
import tornado.web
from urls import urlpatterns
from db.db import Database
from config.config import Settings
from tornado_swirl.swagger import Application, describe
from tornado_swirl import api_routes
from tornado.options import define, options
settings = Settings()
describe(title='UMS API', description='Manages User Operations')
define('mongo_host', default='127.0.0.1:')
class MyApplication(object):
def __init__(self):
self.database = Database()
self.initiateApp()
def initiateApp(self):
app = self.make_app()
app.listen(8888)
def make_app(self):
db = self.database.get_motor_connection()
return tornado.web.Application(api_routes(),
db = db,
cookie_secret=settings.CookieSecret,
debug=settings.Debug,
key_version=settings.KeyVersion,
version=settings.Version,
login_url='api/login'
)
class MainHandler(tornado.web.RequestHandler):
"""This is the main handler"""
def get(self):
self.write("Hello, world")
if __name__ == "__main__":
app = MyApplication()
print("server is running on 8888")
tornado.ioloop.IOLoop.current().start()
io_loop = tornado.ioloop.IOLoop.instance()