def process_data(): try: name = request.form['name'] description = request.form['description'] image = request.files['image'] print "getting data from image..." try: data = rekognize.analyze(image, image.filename) if isinstance(data, list): # some necessarily evil for csv conversion temp_lst = [] for _ in data: temp_lst.append({"Data": _}) data = temp_lst data = json.dumps(data) print data except Exception as e: data = "No data" debug("Failed to analyze image:", e) dataset = Dataset(name, description, data) db.session.add(dataset) db.session.commit() except Exception as e: print debug("Failed to add image:", e) pass return redirect(url_for('index'))
def process_data(): try: name = request.form['name'] description = request.form['description'] image = request.files['image'] print "getting data from image..." db.session.add(dataset) rekognize.analyze(image, image.filename) except Exeption as e: print 'Failed to add image: Error on line {}'.format(sys.exc_info()[-1].tb_lineno), type(e).__name__, e dataset = Dataset(name, description, "data") db.session.add(dataset) db.session.commit()
def process_data(): try: name = request.form['name'] description = request.form['description'] image = request.files['image'] print try: rekognize.analyze(image, image.filename) except Exeption as e: print 'Failed to add image: Error on line {}'.format(sys.exc_info()[-1].tb_lineno), type(e).__name__, e dataset = Dataset(name, description, "data") db.session.add(dataset) db.session.commit() except Exception as e: print 'Failed to add image: Error on line {}'.format(sys.exc_info()[-1].tb_lineno), type(e).__name__, e pass return redirect(url_for('index'))
def process_data(): try: name = request.form['name'] print(name) url_string = request.form['url_string'] print(url_string) #Assuming either image will be input or url (not perfect) #if(image is None): text = url.TEXTviaURL(url_string) #else: # data = rekognize.analyze(image, image.filename) # text = "" #for d in data: #text += d print(text) description = url.summarize(url.wordSearch(text)) print(description) #Adds new value to db dataset = Dataset(name, description) print(dataset) db.session.add(dataset) db.session.commit() except Exception as e: name = request.form['name'] image = request.files['image'] print("getting data from image...") data = rekognize.analyze(image, image.filename) text = "" for d in data: text += d + " " print(text) description = url.summarize(url.wordSearch(text)) print(description) #Adds new value to db dataset = Dataset(name, description) print(dataset) db.session.add(dataset) db.session.commit() #print(debug("Failed to input data:", e)) #pass return redirect(url_for('index'))