Skip to content

Instantly share code, notes, and snippets.

@mrcrilly
Last active December 14, 2023 23:25
Show Gist options
  • Save mrcrilly/05485727d9146dd1ae8eefb6cd07e1ab to your computer and use it in GitHub Desktop.
Save mrcrilly/05485727d9146dd1ae8eefb6cd07e1ab to your computer and use it in GitHub Desktop.
Basic Pythn/Flask/Jinja2 for-loop
# templates/product.html
# change the HTML to suit your needs
<h1>{{ product.name }}</h1>
<p>{{ product.description }}</p>
<p>Price: ${{ product.price }}</p>
# app.py
# ...
@app.route('/product/<product_id>')
def exmaple(product_id):
product = Products.query.filter_by(product_id=product_id).first()
return render_template('product.html', people=product)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment