How to pass and display list of images in flask

Viewed 680

I on working Book recommendation with flask and ml , so i have collected the book's images link in a list, but can't able to figure out how to display those list of images in templates.

this is code where i have the passed the parameter to the templates

@app.route('/search',methods=['GET','POST'])
def search():
choice = request.args.get('search')
# removing all the characters except alphabets and numbers.
# passing the choice to the recommend() function
# passing the choice to the recommend() function
books = recommend(choice)
image=get_image(books)
# if rocommendation is a string and not list then it is else part of the
# recommend() function.
if type(books) == type('string'):
    return render_template('read.html', book=books,image=image,s='opps')
else:
    return render_template('read.html', book=books,image=image)

But i would not figure anyway to display those list of image in my main template. can you help me out with this..

Thank you in advance

1 Answers

Use jinja for loop for it. Assuming list of link is images

{% for item in images %}
    <li><img src="{{item}}" width="500" height="600"></li>
{% endfor %}
Related