def post(self, type=None): self.set_header('Content-Type', 'application/json') jsonM = Data() getJson = self.request.body jsondata = json.loads(getJson) __is_base64 = False __image = None if 'url' in jsondata['query'].keys(): __image = jsondata['query']['url'] else: __image = jsondata['query']['base64'] __is_base64 = True if __image is None: raise Exception('image data is empty!') __name = jsondata['query']['name'] __id = jsondata['query']['id'] __data = jsondata['query']['data'] # 需要参与搜索的字段 __search = jsondata['query']['search'] __data['id'] = __id # 直接使用 application 的 redis 初始化 Manage(self.application.r).index_image(__id, __search, __data, __image, __name, __is_base64) return self.write( jsonM.setStatus('status', 'OK').set('msg', str('index success!')).get())
def delete(self, type=None): try: # os.remove(os.environ[config.STORAGE_INDEX_DB]) Manage(self.application.r).clear_db() except: pass self.set_header('Content-Type', 'application/json') jsonM = Data() self.write( jsonM.setStatus('status', 'OK').set('msg', str('delete index Success!')).get())
def delete(self, type=None): try: # os.remove(os.environ[config.STORAGE_INDEX_DB]) Manage( self.application.r ).clear_db() except: pass self.set_header('Content-Type', 'application/json') jsonM = Data() self.write(jsonM.setStatus('status', 'OK') .set('msg', str('delete index Success!')) .get())
def post(self, type=None): self.set_header('Content-Type', 'application/json') jsonM = Data() getJson = self.request.body jsondata = json.loads(getJson) __is_base64 = False __image = None if 'url' in jsondata['query'].keys(): __image = jsondata['query']['url'] else: __image = jsondata['query']['base64'] __is_base64 = True if __image is None: raise Exception('image data is empty!') __name = jsondata['query']['name'] __id = jsondata['query']['id'] __data = jsondata['query']['data'] # 需要参与搜索的字段 __search = jsondata['query']['search'] __data['id'] = __id # 直接使用 application 的 redis 初始化 Manage( self.application.r ).index_image( __id, __search, __data, __image, __name, __is_base64 ) return self.write(jsonM.setStatus('status', 'OK') .set('msg', str('index success!')) .get())