def init_app(self): api = API(log=self.log) api.register(Sentence_highlight(self.log, self.args), 'Sentence_highlight', 'v1') return tornado.web.Application([ (r'^/api/.*', RequestHandler, dict(api=api, log=self.log)), (r'^/healthcheck', HealthCheck, dict(args=self.args)), ])
class WordVecSpaceServer(object): def __init__(self, input_dir, port, log=Logger): self.input_dir = input_dir self.port = port self.log = log def start(self): self.api = API(log=self.log) self.api.register(APIFunctions(self.input_dir), 'v1') app = self._make_app() app.listen(self.port) tornado.ioloop.IOLoop.current().start() def _make_app(self): return tornado.web.Application([ (r'^/api/.*', RequestHandler, dict(api=self.api)), ])
task: new/declined/accepted ''' if not kwargs: raise Exception( 'Atleast one argument should be passed to perform an update operation' ) food_obj = Food.objects.filter(order_no=order_no) if not food_obj: raise Exception('order does not exists') collection_fields = [f.name for f in Food._meta.fields] invalid_fields = list( set([x.lower() for x in kwargs.keys()]) - set(collection_fields)) if invalid_fields: raise Exception('invalid_fields: {}'.format(invalid_fields)) try: food_obj.update(**kwargs, dt_updated=CURRENT_TIMESTAMP) return "Updated record with the given parameters." except: raise Exception('Failed to update !!') api = API(Logger) api.register(FoodApp(), 'v1')