class DisDeepService(object): def __init__(self): self.config = ApiConfig() def start(self): app = tornado.web.Application([(r"/v1/train", TrainHandler)]) app.listen(self.config.getint("service", "port")) logging.info("service start ...") tornado.ioloop.IOLoop.current().start()
class DisDeepService(object): def __init__(self): self.config = ApiConfig() def start(self): settings = { "cookie_secret": "bZJc2sWbQLKos6GkHn/VB9oXwQt8S0R0kRvJ5/xJ89E=" } app = tornado.web.Application( [(r"/v1/train", TrainHandler), (r"/v1/serving", ServingHandler), (r"/v1/test", TestHandler), (r"/v1/user/([a-zA-Z0-9_-]+)", UserHandler), (r"/v1/upload/(.*)", UploadHandler)], **settings) app.listen(self.config.getint("service", "port")) logging.info("service start ...") tornado.ioloop.IOLoop.current().start()
def __new__(cls, *args, **kwargs): if not hasattr(cls, 'instance'): conf = ApiConfig() cls.instance = super(RedisHelper, cls).__new__(cls) cls.redis = redis.Redis(host=conf.get("redis", "host"), port=conf.getint("redis", "port")) return cls.instance