Exemplo n.º 1
0
def new_image():
    if request.method == 'POST':
        title = request.form['title']
        tags = request.form['tags']
        url = request.form['url']

        try:
            img = Image(title, tags, url)
        except Exception as e:
            return render_template("error.html", message=str(e))

        img.add_to_db(es)

        return render_template("success.html")
    else:
        return render_template("form.html")
Exemplo n.º 2
0
 def test_add_to_db(self):
     img = Image(self.img_name, self.img_tags, self.img_url)
     id = img.add_to_db(es, index=self.index_name)['_id']
     es.get(index=self.index_name, id=id)
     es.delete(index=self.index_name, id=id)