Example #1
0
 def __init__(self, mysql_database=None):
     settings = dict(
         site_title=u"环讯MIS",
         template_path=os.path.join(os.path.dirname(__file__), "templates"),
         static_path=os.path.join(os.path.dirname(__file__), "static"),
         # xsrf_cookies=True,
         cookie_secret="__TODO:_GENERATE_YOUR_OWN_RANDOM_VALUE_HERE__",
         login_url="/login",
         debug=options.debug,
     )
     handles = Route.get_routes()  # defined with route decorators
     tornado.web.Application.__init__(self, handles, **settings)
     # self.database = mysql_database and mysql_database or options.mysql_database
     self.static_path = settings["static_path"]
Example #2
0
def main():
    tornado.options.parse_command_line()
    if options.showurls:
        for each in Route.get_routes():
            print each._path.ljust(20), "mapping to RequestHandle-->", each.handler_class.__name__
    http_server = tornado.httpserver.HTTPServer(Application(), xheaders=True)
    print "Starting tornado server on port", options.port
    if options.prefork:
        print "\tpre-forking"
        http_server.bind(options.port)
        http_server.start()
    else:
        http_server.listen(options.port)
    try:
        tornado.ioloop.IOLoop.instance().start()
    except KeyboardInterrupt:
        pass
Example #3
0
 def __init__(self, mysql_database=None):
     settings = dict(
         site_title=u"培优网-约课系统",
         template_path=os.path.join(os.path.dirname(__file__), "templates"),
         static_path=os.path.join(os.path.dirname(__file__), "static"),
         ui_modules={"GradeEntry": GradeEntry},
         # xsrf_cookies=True,
         cookie_secret="__TODO:_GENERATE_YOUR_OWN_RANDOM_VALUE_HERE__",
         login_url="/login",
         debug=options.debug,
     )
     handles = Route.get_routes()  # defined with route decorators
     tornado.web.Application.__init__(self, handles, **settings)
     self.database = mysql_database and mysql_database or options.mysql_database
     self.db = torndb.Connection(
         host=options.mysql_host, database=self.database,
         user=options.mysql_user, password=options.mysql_password)
     # self.solr_path = options.solr_path
     self.static_path = settings["static_path"]
     self.db_model = set_model(self.db)