24/08/22 - 12h00

master
ChérifBALDE 2022-08-24 12:02:38 +02:00 committed by cherif
parent 0a6ef30dd5
commit 2fc85a666b
2 changed files with 37 additions and 1 deletions

11
main.py
View File

@ -1280,6 +1280,17 @@ def createOrder():
status, message, order_id = invoice.createOrder(payload)
return jsonify(status=status, message=message, order_id=order_id)
"""
Cette API retourne la liste des mots suggerés pour la recherche
"""
@app.route('/myclass/api/Get_Suggested_Word/', methods=['GET','POST'])
@crossdomain(origin='*')
def Get_Suggested_Word():
# On recupere le corps (payload) de la requete
payload = request.form.to_dict()
print(" ### payload = ", str(payload))
status, message = mycommon.Get_Suggested_Word()
return jsonify(status=status, message=message)
if __name__ == '__main__':
print(" debut api")

View File

@ -1540,4 +1540,29 @@ def UpdateMetier():
except Exception as e:
exc_type, exc_obj, exc_tb = sys.exc_info()
print(str(inspect.stack()[0][3]) + " -" + str(e) + " - ERRORRRR AT Line : " + str(exc_tb.tb_lineno))
return False
return False
"""
Cette fonction retroune les mots suggerés au format JSON
"""
def Get_Suggested_Word():
try:
nb_result = 0
insertObject = []
coll_name = MYSY_GV.dbname['search_suggestion_words']
for x in coll_name.find({}, {'_id':0}).sort([("mot", pymongo.ASCENDING), ]):
nb_result = nb_result + 1
val_tmp = {}
val_tmp['id'] = str(nb_result)
val_tmp['name'] = x['mot']
insertObject.append(JSONEncoder().encode(val_tmp))
return True, insertObject
except Exception as e:
exc_type, exc_obj, exc_tb = sys.exc_info()
print(str(inspect.stack()[0][3]) + " -" + str(e) + " - ERRORRRR AT Line : " + str(exc_tb.tb_lineno))
return False, False