#!/usr/bin/env python
# coding=utf-8

import tornado.ioloop
import tornado.web
from tornado.log import gen_log
from handler import UserHandler
from handler import UserIdHandler
from handler import TempHandler
from handler import TempIdHandler
from handler import TempsHandler
import db


class MainHandler(tornado.web.RequestHandler):
    def get(self):
        self.write("Hello, world")


def make_app():
    setting = dict(
        debug=True,
        login_url='/'
    )
    return tornado.web.Application([
        (r"/", MainHandler),
        (r"/user/*", UserHandler),
        (r"/users/(.+)/*", UserIdHandler),
        (r"/users/(.+)/temps/*", TempHandler),
        (r"/users/(.+)/temps/(.+)/*", TempIdHandler),
        (r"/temps", TempsHandler),
    ], **setting)

if __name__ == "__main__":
    from tornado.log import enable_pretty_logging
    enable_pretty_logging()
    gen_log.info(db.uri)
    gen_log.info("http://localhost:8888")
    app = make_app()
    app.listen(8888)
    tornado.ioloop.IOLoop.current().start()

#!/usr/bin/env python
# coding=utf-8

import tornado.ioloop
import tornado.web
from tornado.log import gen_log
from tornado.options import define
from tornado.options import options
from handler import UserHandler
from handler import UserIdHandler
from handler import TempHandler
from handler import TempIdHandler
from handler import TempsHandler
import db

define("port", type=int, default=8888, help="Run server on a specific port")
       
       
class MainHandler(tornado.web.RequestHandler):
    def get(self):
        self.write("Hello, world")


def make_app():
    setting = dict(
        debug=True,
        login_url='/'
    )
    return tornado.web.Application([
        (r"/", MainHandler),
        (r"/user/*", UserHandler),
        (r"/users/(.+)/*", UserIdHandler),
        (r"/users/(.+)/temps/*", TempHandler),
        (r"/users/(.+)/temps/(.+)/*", TempIdHandler),
        (r"/temps", TempsHandler),
    ], **setting)

if __name__ == "__main__":
    from tornado.log import enable_pretty_logging
    enable_pretty_logging()
    options.parse_command_line()
    gen_log.info(db.uri)
    gen_log.info("http://localhost:{}".format(options.port))
    app = make_app()
    app.listen(options.port)
    tornado.ioloop.IOLoop.current().start()

add port define