I have a page full of images I want to load webpage with custom data for each product
example
a online shopping website which load same layout but different prices and description
For the layout, you will build a template in html an in jinja.
You will use tags that look like:
<title>{% block title %}{% endblock %}</title>
<ul>
{% for user in users %}
<li><a href="{{ user.url }}">{{ user.username }}</a></li>
{% endfor %}
</ul>
To render your template, you will use code that looks like:
from flask import render_template
@app.route('/hello/')
@app.route('/hello/<name>')
def hello(name=None):
return render_template('hello.html', name=name)
Quickstart Rendering Templates
The template can serve as the same page, you can use routing and variable rules (viewable in above code) to build subsequent urls that use the same template, those page names can be read so you know which information to fetch from your database or files, and send that information into the template to replace the jinja tags.
I dont need loop,I have somthing like this
<a href="https://image1.com"><img src="ggg"></a>
so should I do
@app.route('/hello/')
@app.route('/hello/<link>')
def hello(link=None):
return render_template('hello.html', link=link)
and then load the image accoring to link