def clickGet(): images = getImages(1) attribute = getAttributes(1) return jsonEncoder.encode({ 'images': images, 'attribute': attribute, }), 200
def grammarGet(): images = getImages(2) grammar = getGrammarJSON(getGrammar()) return jsonEncoder.encode({ 'images': images, 'grammar': grammar, }), 200
def recognitionGet(): images = getImages(1) classLabel = getClassLabel(1) return jsonEncoder.encode({ 'images': images, 'classLabel': classLabel }), 200
def chooseGet(): images = getImages(2) adverb = getAdverbs(1) adjective = getAdjectives(1) return jsonEncoder.encode({ 'images': images, 'adverb': adverb, 'adjective': adjective, }), 200
def clickPost(): data = json.loads(request.data) image = getPostedImages(data['images']) attribute = data['attribute'] choice = data['choice'] point = data['point'] post = { **image, 'attribute': attribute, 'choice': choice, 'x': point['x'], 'y': point['y'], } RESULT_DB.db['click'].insert_one(post) print(post) with open('clickTaskResult.json', 'w') as out: out.write(jsonEncoder.encode(post)) return jsonEncoder.encode(post), 200
def choosePost(): data = json.loads(request.data) images = getPostedImages(data['images']) adverb = data['adverb'] adjective = data['adjective'] choice = data['choice'] # which image did they choose (image0 or image1) post = { **images, 'adverb': adverb, 'adjective': adjective, 'choice': choice, } RESULT_DB.db['choose'].insert_one(post) return jsonEncoder.encode(post), 200