Last active
December 14, 2023 23:25
-
-
Save mrcrilly/05485727d9146dd1ae8eefb6cd07e1ab to your computer and use it in GitHub Desktop.
Basic Pythn/Flask/Jinja2 for-loop
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# templates/product.html | |
# change the HTML to suit your needs | |
<h1>{{ product.name }}</h1> | |
<p>{{ product.description }}</p> | |
<p>Price: ${{ product.price }}</p> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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