forked from nekocode/tornaREST
-
Notifications
You must be signed in to change notification settings - Fork 0
/
server.py
28 lines (21 loc) · 744 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
#!/usr/bin/env python
# coding:utf-8
import tornado.ioloop
import tornado.options
import tornado.httpserver
from application import app
from tornado.options import define, options, parse_command_line
from motorengine import connect
import config
define("port", type=int, default=80, help="run on the given port")
def main():
parse_command_line()
http_server = tornado.httpserver.HTTPServer(app)
http_server.listen(options.port)
print 'Server is running at http://127.0.0.1:%s/' % options.port
print 'Quit the server with Control-C'
io_loop = tornado.ioloop.IOLoop.instance()
connect("local", host=config.DB_HOST, port=config.DB_PORT, io_loop=io_loop)
io_loop.start()
if __name__ == "__main__":
main()