-
Notifications
You must be signed in to change notification settings - Fork 0
/
server.py
51 lines (38 loc) · 1.3 KB
/
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
import os
import tornado.options
import tornado.web
from tornado.ioloop import IOLoop
from db import DBHelper
from routes.api_config_route import api_config_route
from routes.data_fetch_route import data_fetch_routes
from routes.word_route import word_routes
class MainHandler(tornado.web.RequestHandler):
def data_received(self, chunk):
pass
def get(self):
# TODO generate Dummy data will be removed on production
# user_repository = UserRepository.UserRepository()
# user_repository.bulk_insert()
self.write('Hi I Am Windy Tornado\n Avaliable Routes \n\
http:localhost:3000/api/v1/users')
class Application(tornado.web.Application):
def __init__(self):
handlers = [
(r"/?", MainHandler)
]
settings = {
'debug': True
}
# This Method is to add all the routes from Route Package
handlers.extend(word_routes)
handlers.extend(data_fetch_routes)
handlers.extend(api_config_route)
tornado.web.Application.__init__(self, handlers, settings)
tornado.options.parse_command_line()
def main():
app = Application()
DBHelper().genschema()
app.listen(os.getenv("PORT",3000))
IOLoop.instance().start()
if __name__ == '__main__':
main()